在我感兴趣的一行代码上,如何从命令行执行“ git blame”?

Low*_*ong 6 git command-line

本质上,我想做的是我们通常使用Web界面所做的相同的事情。我知道如何git blame使用Web界面说bitbucket或github,但是如何使用git CLI做同样的事情?到目前为止,我到目前为止:

  1. git grep <line of code that I am interested to see the blame>。获取文件列表,然后找到我感兴趣的文件。
  2. git blame <on file of interest>。显示谁做了什么并提交哈希。
  3. 无法弄清楚这部分...我看到了我感兴趣的哈希,如何仅看到一个提交哈希就看到完整的提交日志?

Low*_*ong 6

发布后,我偶然发现了这个http://zsoltfabok.com/blog/2012/02/git-blame-line-history/,因此我将其发布在这里以供参考。这些步骤是:

  1. 找到您感兴趣的行号,然后怪罪于此git blame -L <starting line number>,<ending line number> <filename>。(即行号用逗号分隔,没有空格)
  2. git show <commit hash> 会告诉您您需要了解的内容。