git blame displays the last author that modified a line, often times you will want to know when a line was originally added. This can be cumbersome to achieve using
git blame. It requires a combination of the
-M options. It can be far more convenient to use the git log command.
-S 选项附加到您要查找的代码中。我们以上方 README 输出中的一行为例。我们从 README 输出的第 12 行中提取文本 "CSS3D and WebGL renderers"。
$ git log -S"CSS3D and WebGL renderers." --pretty=format:'%h %an %ad %s'
e339d3c85 Mario Schuettel Tue Oct 13 16:51:06 2015 +0200 reverted README.md to original content
509c2cc35 Daniel Tue Sep 8 13:56:14 2015 +0200 Updated README
cb20237cc Mr.doob Mon Dec 31 00:22:36 2012 +0100 Removed DOMRenderer. Now with the CSS3DRenderer it has become irrelevant.
This output shows us that content from the README was added or modified 3 times by 3 different authors. It was originally added in commit cb20237cc by Mr.doob. In this example,
git log has also been prepended with the
--pretty-format option. This option converts the default output format of
git log into one that matches the format of
git log. For more information on usage and configuration options visit the git log page.