查看提交历史在提交了若干更新又或者克隆了某个项目之后你也许想回顾下提交历史。 完成这个任务最简单而又有效的工具是 git log 命令。接下来的例子会用我专门用于演示的 simplegit 项目 运行下面的命令获取该项目源代码git clone https://github.com/schacon/simplegit-progit然后在此项目中运行 git log应该会看到下面的输出$ git log commit ca82a6dff817ec66f44342007202690a93763949Author:ScottChaconschacongee-mail.comDate:MonMar1721:52:112008-0700changed the version number commit085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7Author:ScottChaconschacongee-mail.comDate:SatMar1516:40:332008-0700removed unnecessary test commit a11bef06a3f659402fe7563abf99ad00de2209e6Author:ScottChaconschacongee-mail.comDate:SatMar1510:31:282008-0700first commit默认不用任何参数的话git log 会按提交时间列出所有的更新最近的更新排在最上面。 正如你所看到的这个命令会列出每个提交的 SHA-1 校验和、作者的名字和电子邮件地址、提交时间以及提交说明。git log 有许多选项可以帮助你搜寻你所要找的提交 接下来我们介绍些最常用的。一个常用的选项是 -p用来显示每次提交的内容差异。 你也可以加上 -2 来仅显示最近两次提交$ git log-p-2commit ca82a6dff817ec66f44342007202690a93763949Author:ScottChaconschacongee-mail.comDate:MonMar1721:52:112008-0700changed the version number diff--git a/Rakefileb/Rakefileindex a874b73..8f94139100644---a/Rakefileb/Rakefile-5,75,7 require rake/gempackagetask specGem::Specification.newdo|s|s.platformGem::Platform::RUBYs.namesimplegit-s.version0.1.0s.version0.1.1s.authorScott Chacons.emailschacongee-mail.coms.summaryA simple gem for using Git in Ruby code.commit085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7Author:ScottChaconschacongee-mail.comDate:SatMar1516:40:332008-0700removed unnecessary test diff--git a/lib/simplegit.rb b/lib/simplegit.rb index a0a60ae..47c6340100644---a/lib/simplegit.rbb/lib/simplegit.rb -18,818,3classSimpleGitend end--if$0__FILE__-gitSimpleGit.new-puts git.show-end \Nonewline at end of file