1) A common option is to -p
show the difference in content for each commit. This option, in addition to displaying the basic information, is accompanied by changes in each commit.
$ git log -p -2
Commit Ca82a6dff817ec66f44342007202690a93763949author:scott Chacon <[email protected]>date:mon Mar 17 21:52:11 2008-0700 changed the version numberdiff--git a/rakefile b/rakefileindex a874b73. 8f94139 100644---a/rakefile+++ b/rakefile@@ -5,7 +5,7 @@ require ' rake/gempackagetask ' spec = gem::specification.new do | s| S.platform = Gem::P latform::ruby s.name = "Simplegit"-s.version = "0.1.0" + s.version = "0.1.1 "S.author =" Scott Chacon "s.email =" [email protected] "s.summary =" A simple gem for us ing Git in Ruby code. " Commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7author:scott Chacon <[email protected]>date:sat Mar 15 16:40:33 2008-0700 removed unnecessary testdiff--git a/lib/simplegit.rb b/lib/simplegit.rbindex a0a60ae. 47c6340 100644---a/lib/simplegit.rb+++ b/lib/simplegit.rb@@ -18,8 +18,3 @@ class Simplegit end end--if $ = __file __-git = simplegit.new-puts git.show-end\ No newline at end of file
-
2) you want to see the summary statistics for each submission, you can use the --stat
option. All the modified files are listed below each commit, how many files have been modified, and which lines of the modified files have been removed or added. There is a summary at the end of each submission.
$ git log--stat
commit Ca82a6dff817ec66f44342007202690a93763949author:scott Chacon <[email protected]>date:mon Mar 21:52:11 2008-0700 changed the version number Rakefile | 2 +-1 file changed, 1 insertion (+), 1 deletion (-) Commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7author:scott Chacon < [Email protected]>date:sat Mar 16:40:33 2008-0700 removed unnecessary test LIB/SIMPLEGIT.RB | 5-----1 File changed, 5 deletions (-) Commit A11bef06a3f659402fe7563abf99ad00de2209e6author:scott Chacon <[email& Nbsp;protected]>date:sat Mar 10:31:28 2008-0700 First Commit README | 6 ++++++ Rakefile | +++++++++++++++++++++++ LIB/SIMPLEGIT.RB | +++++++++++++++++++++++++ 3 files changed, insertions (+)
3) Another common option is --pretty
. This option specifies that the commit history will be displayed in a different way than the default format. This option has some built-in sub-options for you to use. For example, using oneline to put each commit on one line, it is useful to see a large number of commits. In addition, Short,full and fuller can be used, the information displayed is more or less different.
$ git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the version number085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary testa11bef06a3f659402fe7563abf99ad00de2209e6 first commit
But the most interesting thing is format
that you can customize the format of the records to be displayed. This output is particularly useful for post-extraction analysis
$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 6 years ago : changed the version number085bb3b - Scott Chacon, 6 years ago : removed unnecessary testa11bef0 - Scott Chacon, 6 years ago : first commit
- The commonly used options for
-
git log--pretty=format
list the commonly used format placeholder notation and the meaning it represents.
Options | Description------|-------------------------------------%H | Full hash string for commit (commit)%h | Short hash string for the Commit object%T | Full hash string%t of tree Object | Short hash string for tree object%P | Full hash string%p of Parent Object | Short hash string for parent object%an | The name of the author (author)%ae | Author's email address%ad | Author revision date (can be customized with--date= option)%ar | Author revision date, as of how long ago the Way show%CN | The name of the submitter (committer)%ce | Submitter's email address%CD | Date of submission%CR | Date of submission, how long before the way the%s was displayed | Submission Description
This is especially useful when oneline or format is used in conjunction with another log option --graph
. This option adds some ASCII strings to visualize your branch and merge history.
$ git log --pretty=format:"%h %s" --graph
* 2d3acf9 ignore errors from SIGCHLD on trap* 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit|| * 420eac9 Added a method for getting the current branch.* | 30e367c timeout code and tests* | 5a09431 add timeout protection to grit* | e1193f8 support for heads with slashes in them|/* d6016bc require time for xmlschema* 11d191e Merge branch 'defunkt' into local