[小技巧] 如何在 git 里查找哪一个 commit 删除了代码的一行

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 01:28   538   0

本文转载至:http://stackoverflow.com/questions/4404444/how-do-i-blame-a-deleted-line

If you know the contents of the line, this is an ideal use case for:

git log -S <string> path/to/file

which shows you commits which introduce or remove an instance of that string. There's also the -G<regex> which does the same thing with regular expressions! See man git-log and search for the -G and -S options, or pickaxe (the friendly name for these features) for more information.

The -S option is actually mentioned in the header of the git-blame manpage too, in the description section, where it gives an example using git log -S....


说明:使用git log 的 -S 选项来指定 commit 里包括的字符串。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP