我如何“混淆责任”?删除的行? [英] How do I "git blame" a deleted line?

查看:66
本文介绍了我如何“混淆责任”?删除的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git blame 非常适合修改和添加行,但是如何才能找到何时存在于特定以前提交中的行最终被删除。我正在考虑 bisect ,但我希望有更便利的方式。 $ b

[在你问之前:我只是做了一个 git log -p 并搜索了代码行,(a)一些白痴已经删除了以前的关键代码行 提交和(b)我是那个白痴]

解决方案

如果您知道该行的内容,这是一个理想的用例for:

  git log -S  path / to / file 

它显示你提交哪个引入或删除该字符串的实例。还有 -G< regex> ,它对正则表达式做同样的事情!查看 man git-log 并搜索 -G -S $ b

-S 选项或镐(这些功能的友好名称)选项实际上在 git-blame 手册页的标题中提到,在描述部分中,它使用 git log -S来举例说明。 ..


git blame is great for modified and added lines but how can I find when a line that existed in a specific previous commit was eventually deleted. I'm thinking bisect but I was hoping for something handier.

[ before you ask: in the case, I just did a git log -p and searched through for the code line and (a) some idiot had just deleted the vital line in the previous commit and (b) I was that idiot ]

解决方案

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....

这篇关于我如何“混淆责任”?删除的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆