git log:浏览提交历史
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon [email protected]
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon [email protected]
Date: Sat Mar 15 16:40:33 2008 -0700
removed unnecessary test
commit a11bef06a3f659402fe7563abf99ad00de2209e6
Author: Scott Chacon [email protected]
Date: Sat Mar 15 10:31:28 2008 -0700
first commit
提交越新越靠上,并且有40位hash码。
git log -p 2 查看最新两个提交历史
$ git log -p -2
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <[email protected]>
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
diff --git a/Rakefile b/Rakefile
index a874b73..8f94139 100644
--- a/Rakefile
+++ b/Rakefile
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::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 using Git in Ruby code."
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <[email protected]>
Date: Sat Mar 15 16:40:33 2008 -0700
removed unnecessary test
diff --git a/lib/simplegit.rb b/lib/simplegit.rb
index a0a60ae..47c6340 100644
--- a/lib/simplegit.rb
+++ b/lib/simplegit.rb
@@ -18,8 +18,3 @@ class SimpleGit
end
end
-
-if $0 == __FILE__
- git = SimpleGit.new
- puts git.show
-end
git log -stat命令
查看历史提交的缩略统计版本输出
git log --pretty=oneline 格式化输出内容
git log --pretty=format:"%h - %an, %ar : %s"
git log –-pretty=format: 下的一些有用的参数
Table 1. Useful options for git log --pretty=format
Option Description of Output
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author email
%ad Author date (format respects the --date=option)
%ar Author date, relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date, relative
%s Subject
git log命令的一些选项
Table 2. Common options to git log
Option | Description |
---|---|
-p | Show the patch introduced with each commit. |
–stat | Show statistics for files modified in each commit. |
–shortstat | Display only the changed/insertions/deletions line from the --stat command. |
–name-only | Show the list of files modified after the commit information. |
–name-status | Show the list of files affected with added/modified/deleted information as well. |
–abbrev-commit | Show only the first few characters of the SHA-1 checksum instead of all 40. |
–relative-date | Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format. |
–graph | Display an ASCII graph of the branch and merge history beside the log output. |
–pretty | Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format). |
–oneline | Shorthand for --pretty=oneline --abbrev-commit used together. |
git log过滤输出选项
Table 3. Options to limit the output of git log
Option | Description |
---|---|
-<n> | Show only the last n commits |
–since, --after | Limit the commits to those made after the specified date. |
–until, --before | Limit the commits to those made before the specified date. |
–author | Only show commits in which the author entry matches the specified string. |
–committer | Only show commits in which the committer entry matches the specified string. |
–grep | Only show commits with a commit message containing the string |
-S | Only show commits adding or removing code matching the string |
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。