查找何时删除了行 [英] Find when line was deleted

查看:67
本文介绍了查找何时删除了行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天早些时候,我发现我的git存储库中缺少一些代码。我知道一些缺失的文本以及它所在的文件,所以我使用了 git log -S'missingtext'/ path / to / file 。但是,唯一返回的是我添加了包含缺失文本的行的提交。这个文本并没有出现在HEAD中,添加它的提交出现在我的分支中,所以我知道我的分支历史记录中的一个提交必须删除它,但它没有显示出来。



经过一些手动搜索后,事实证明该线路在解决合并冲突时被意外删除。所以我想知道:


  1. 这是扒手无法找到删除该行的提交的原因吗?
  2. b $ b
  3. 如何在没有手动查看历史记录的情况下找到missingtext被删除的位置?

#1会很好(我认为 git log -S - / code>会给我我的答案),但我真正的问题是#2,因为我希望能够避免这在未来。

解决方案

git log 不显示diff默认为合并提交。 -c - cc 标志应该有效:

git log -c -S'missingtext'/ path / to / file



更多讨论/解释此处


Earlier today I discovered that some code was missing from my git repository. I knew some of the missing text, and the file that it was in, so I used git log -S'missingtext' /path/to/file. However, the only thing that came back was the commit in which I added the line containing the missing text. The text wasn't present in HEAD, and the commit that added it was present in my branch, so I knew that one of the commits in my branch's history must have removed it, but it wasn't showing up.

After some manual searching, it turned out that the line was removed accidentally while resolving a conflict for a merge. So I'm wondering:

  1. Is this the reason why pickaxe couldn't find the commit that deleted the line?
  2. How could I have found where "missingtext" was deleted without digging through the history manually?

Any insight on #1 would be great (I assumed that git log -S would give me my answer), but my real question is #2 since I'd like to be able to avoid this in the future.

解决方案

git log doesn't shows a diff for merge commits by default. The -c or --cc flags should do the trick:

git log -c -S'missingtext' /path/to/file

More discussion/explanation here.

这篇关于查找何时删除了行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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