Chinaunix首页 | 论坛 | 博客
  • 博客访问: 186177
  • 博文数量: 34
  • 博客积分: 869
  • 博客等级: 准尉
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-08 15:55
文章分类

全部博文(34)

文章存档

2012年(34)

我的朋友

分类: 项目管理

2012-03-29 11:20:19

Git reviewing the history first of all, began to introduce the new command
Please quickly preview some command.

点击(此处)折叠或打开

  1. $ git log v2.5.. # commits since (not reachable from) v2.5

  2. $ git log test..master # commits reachable from master but not test

  3. $ git log master..test # commits reachable from test but not master

  4. $ git log master...test # commits reachable from either test or

  5. $ git log --since="2 weeks ago" # commits from the last 2 weeks

  6. $ git log Makefile # commits that modify Makefile

  7. $ git log fs/ # commits that modify any file under fs/

  8. $ git log -S'foo()' # commits that add or remove any file data

  9. $ 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

点击(此处)折叠或打开

  1. commit 7d7e2694c0b7b1715319ca6f8df208899afc790
  2. Author: qutao
  3. Date: Wed Mar 28 16:58:37 2012 +0800
  4. commit all
  5. commit d093ce51b7c3737769d015baa2c26c02c038093d
  6. Author: qutao
  7. Date: Wed Mar 28 16:18:11 2012 +0800
  8. add the file some content
1. if you want to see what the patch of every commit, then please add the argument -p

点击(此处)折叠或打开

  1. git log -p
  2. commit c08dc95d3ef6f07555df142b7a99df2ee4602694
  3. Author: qutao
  4. Date: Wed Mar 28 19:04:12 2012 +0800
  5. commit infomation
  6. diff --git a/file0 b/file0
  7. index b5c99ac..97cd697 100644
  8. --- a/file0
  9. +++ b/file0
  10. @@ -1,4 +1,7 @@
  11. @####i
  12. 8888888888888888888888888888
  13. afadf
  14. -99999999999999
  15. +99999999999999i
  16. +
  17. +
  18. +adfad
  19. commit ed265f4b1d3da788616c93fccbd283b6346705d6
  20. Author: qutao
  21. Date: Wed Mar 28 19:00:29 2012 +0800
  22. add the ohers file
  23. diff --git a/file1 b/file1
  24. new file mode 100644
  25. index 0000000..8012e4c
  26. --- /dev/null
  27. +++ b/file1
  28. @@ -0,0 +1 @@
  29. +iiadfadfa
  30. 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.

点击(此处)折叠或打开

  1. $ git log –stat
  2. commit c08dc95d3ef6f07555df142b7a99df2ee4602694
  3. Author: qutao
  4. Date: Wed Mar 28 19:04:12 2012 +0800
  5. commit infomation
  6. file0 | 5 ++++-
  7. 1 files changed, 4 insertions(+), 1 deletions(-)
  8. commit ed265f4b1d3da788616c93fccbd283b6346705d6
  9. Author: qutao
  10. Date: Wed Mar 28 19:00:29 2012 +0800
  11. add the ohers file
  12. file1 | 1 +
  13. file2 | 4 ++++
  14. file3 | 6 ++++++
  15. 3 files changed, 11 insertions(+), 0 deletions(-)
  16. commit a88261b015f00fb7834c7ddcf6306c3471d986a
3. Formatting the log

you can  format the log output you wanted, –pretty option can take a number of format

点击(此处)折叠或打开

  1. git log –pretty=oneline
  2. 8d41d022d7f90e9c53dd7da07da854e0008b5b98 Merge branch 'exprimental'
  3. c08dc95d3ef6f07555df142b7a99df2ee4602694 commit infomation
  4. ed265f4b1d3da788616c93fccbd283b6346705d6 add the ohers file
  5. ca88261b015f00fb7834c7ddcf6306c3471d986a commit hard
  6. 77d7e2694c0b7b1715319ca6f8df208899afc790 commit all
  7. d093ce51b7c3737769d015baa2c26c02c038093d add the file some content
  8. 6cac10e87f60abc23de4ddae5ebc871d1b87f708 add the file0
or

点击(此处)折叠或打开

  1. git log –pretty=short
  2. commit 8d41d022d7f90e9c53dd7da07da854e0008b5b98
  3. Merge: ed265f4 c08dc95
  4. Author: qutao
  5. Merge branch 'exprimental'
  6. commit c08dc95d3ef6f07555df142b7a99df2ee4602694
  7. Author: qutao

  8. commit infomation
  9. commit ed265f4b1d3da788616c93fccbd283b6346705d6
  10. Author: qutao
  11. add the ohers file
  12. 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

点击(此处)折叠或打开

  1. git log --pretty=format:'%h : %s' –graph

  2. * 8d41d02 : Merge branch 'exprimental'
  3. |\

  4. | * c08dc95 : commit infomation

  5. * | ed265f4 : add the ohers file

  6. |/

  7. * ca88261 : commit hard

  8. * 77d7e26 : commit all

  9. * d093ce5 : add the file some content
  10. *
  11. 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) |
给主人留下些什么吧!~~