Git reviewing the history first of all, began to introduce the
new command
Please quickly preview some command.
- $ git log v2.5.. # commits since (not reachable from) v2.5
- $ git log test..master # commits reachable from master but not test
- $ git log master..test # commits reachable from test but not master
- $ git log master...test # commits reachable from either test or
- $ git log --since="2 weeks ago" # commits from the last 2 weeks
- $ git log Makefile # commits that modify Makefile
- $ git log fs/ # commits that modify any file under fs/
- $ git log -S'foo()' # commits that add or remove any file data
- $ git log --no-merges # dont show merge commits
and of course you can combine them to use.
when you type the git log the
git system will prompt as blow
- commit 7d7e2694c0b7b1715319ca6f8df208899afc790
- Author: qutao
- Date: Wed Mar 28 16:58:37 2012 +0800
- commit all
- commit d093ce51b7c3737769d015baa2c26c02c038093d
- Author: qutao
- Date: Wed Mar 28 16:18:11 2012 +0800
- add the file some content
1. if you want to see what the patch of
every commit, then please add the argument -p
- git log -p
- commit c08dc95d3ef6f07555df142b7a99df2ee4602694
- Author: qutao
- Date: Wed Mar 28 19:04:12 2012 +0800
- commit infomation
- diff --git a/file0 b/file0
- index b5c99ac..97cd697 100644
- --- a/file0
- +++ b/file0
- @@ -1,4 +1,7 @@
- @####i
- 8888888888888888888888888888
- afadf
- -99999999999999
- +99999999999999i
- +
- +
- +adfad
- commit ed265f4b1d3da788616c93fccbd283b6346705d6
- Author: qutao
- Date: Wed Mar 28 19:00:29 2012 +0800
- add the ohers file
- diff --git a/file1 b/file1
- new file mode 100644
- index 0000000..8012e4c
- --- /dev/null
- +++ b/file1
- @@ -0,0 +1 @@
- +iiadfadfa
- diff --git a/file2 b/file2
expansion the detail of
every commit point
2. if you pass the the –state option to
git log, it will show you which files have changed,
in that commit and how many lines were added and
removed from each.
- $ git log –stat
- commit c08dc95d3ef6f07555df142b7a99df2ee4602694
- Author: qutao
- Date: Wed Mar 28 19:04:12 2012 +0800
- commit infomation
- file0 | 5 ++++-
- 1 files changed, 4 insertions(+), 1 deletions(-)
- commit ed265f4b1d3da788616c93fccbd283b6346705d6
- Author: qutao
- Date: Wed Mar 28 19:00:29 2012 +0800
- add the ohers file
- file1 | 1 +
- file2 | 4 ++++
- file3 | 6 ++++++
- 3 files changed, 11 insertions(+), 0 deletions(-)
- commit a88261b015f00fb7834c7ddcf6306c3471d986a
3. Formatting the log
you can format the log output you wanted, –pretty option can take a number of format
- git log –pretty=oneline
- 8d41d022d7f90e9c53dd7da07da854e0008b5b98 Merge branch 'exprimental'
- c08dc95d3ef6f07555df142b7a99df2ee4602694 commit infomation
- ed265f4b1d3da788616c93fccbd283b6346705d6 add the ohers file
- ca88261b015f00fb7834c7ddcf6306c3471d986a commit hard
- 77d7e2694c0b7b1715319ca6f8df208899afc790 commit all
- d093ce51b7c3737769d015baa2c26c02c038093d add the file some content
- 6cac10e87f60abc23de4ddae5ebc871d1b87f708 add the file0
or
- git log –pretty=short
- commit 8d41d022d7f90e9c53dd7da07da854e0008b5b98
- Merge: ed265f4 c08dc95
- Author: qutao
- Merge branch 'exprimental'
- commit c08dc95d3ef6f07555df142b7a99df2ee4602694
- Author: qutao
- commit infomation
- commit ed265f4b1d3da788616c93fccbd283b6346705d6
- Author: qutao
- add the ohers file
- commit ca88261b015f00fb7834c7ddcf6306c3471d986a
if those formats aren't exactly what
you needed , you can also create you own format with the' – pretty=format' option (see the
git log docs for all the formatting options)another interesting thing you can do is
visualize the commit graph with the '--graph' option like this
点击(此处)折叠或打开
- git log --pretty=format:'%h : %s' –graph
- * 8d41d02 : Merge branch 'exprimental'
- |\
- | * c08dc95 : commit infomation
- * | ed265f4 : add the ohers file
- |/
- * ca88261 : commit hard
- * 77d7e26 : commit all
- * d093ce5 : add the file some content
- *
- 6cac10e : add the file0
6. Ordering log history, you can also view the log entries in a
few different orders
Note: the git log starts with the most
recent commit and works backward through parents
however , since git history can contain
multiple independent lines of development. The particular
order that commits are listed in may be
somewhat arbitrary
if you want to specify a certain order,
you can add an ordering option to the git log command
by default the commits are shown in
reverse chronological order
However, you can also specify
'--topo-order', which makes the commits appear in topological order
(i.e. descendant
commits are shown before their
parents). If we view the git log for the Grit repo in topo-order, you
can see that the
development lines are all grouped
together.
You can also use '--date-order', which
orders the commits primarily by commit date. This option is similar
to --topo-order
in the sense that no parent comes
before all of its children, but otherwise things are still ordered in
the commit timestamp
order. You can see that development
lines are not grouped together here, that they jump around as
parallel development
append:
[rocrocket@wupengchong project]$ git log stable..experimental //将显示在experimental分支但不在stable分支的历史记录
[rocrocket@wupengchong project]$ git log experimental..stable //将显示在stable分支但不在experimental分支的历史记录
git log --decorate 将会显示commit对应的tag decorate v.1. 修饰,装饰,布置
阅读(983) | 评论(0) | 转发(0) |