git-查看提交历史

git log:浏览提交历史
$ git log

commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon schacon@gee-mail.com
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon schacon@gee-mail.com
Date: Sat Mar 15 16:40:33 2008 -0700
removed unnecessary test
commit a11bef06a3f659402fe7563abf99ad00de2209e6
Author: Scott Chacon schacon@gee-mail.com
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 <schacon@gee-mail.com>
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     =   "schacon@gee-mail.com"
     s.summary   =   "A simple gem for using Git in Ruby code."

commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <schacon@gee-mail.com>
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

OptionDescription
-pShow the patch introduced with each commit.
–statShow statistics for files modified in each commit.
–shortstatDisplay only the changed/insertions/deletions line from the --stat command.
–name-onlyShow the list of files modified after the commit information.
–name-statusShow the list of files affected with added/modified/deleted information as well.
–abbrev-commitShow only the first few characters of the SHA-1 checksum instead of all 40.
–relative-dateDisplay the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.
–graphDisplay an ASCII graph of the branch and merge history beside the log output.
–prettyShow commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).
–onelineShorthand for --pretty=oneline --abbrev-commit used together.

git log过滤输出选项
Table 3. Options to limit the output of git log

OptionDescription
-<n>Show only the last n commits
–since, --afterLimit the commits to those made after the specified date.
–until, --beforeLimit the commits to those made before the specified date.
–authorOnly show commits in which the author entry matches the specified string.
–committerOnly show commits in which the committer entry matches the specified string.
–grepOnly show commits with a commit message containing the string
-SOnly show commits adding or removing code matching the string
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值