简体   繁体   English

如何搜索git历史记录以查找消失的行?

[英]How do I search git history for a disappeared line?

I need to search the history of a specific file in a git repository to find a line that is gone. 我需要在git存储库中搜索特定文件的历史记录,以找到一条消失的行。 The commit message will not have any relevant text to search on. 提交消息将没有任何相关文本可供搜索。 What command do I use? 我用什么命令?

Further details: this is the history of my todo list out of our non-stellar task tracking software. 进一步的细节:这是我的非标准任务跟踪软件的todo列表的历史。 I've been keeping it for two years because there's just not enough information kept for me in the software. 我已经保留了两年,因为在软件中没有为我保留足够的信息。 My commit messages usually have only the task ids, unfortunately, and what I need to do is find a closed task by subject, not by number. 遗憾的是,我的提交消息通常只有任务ID,而我需要做的是按主题而不是按编号查找已关闭的任务。 Yes, the real solution is better task tracking software, but that is completely out of my hands. 是的,真正的解决方案是更好的任务跟踪软件,但这完全不在我手中。

This is a job for the pickaxe! 这是镐的工作!

From the git-log manpage: 从git-log手册页:

-S<string>

Look for differences that introduce or remove an instance of <string> . 查找引入或删除<string>实例的差异。 Note that this is different than the string simply appearing in diff output; 请注意,这与简单地出现在diff输出中的字符串不同; see the pickaxe entry in gitdiffcore(7) for more details. 有关更多详细信息,请参阅gitdiffcore(7)中的pickaxe条目。

You can of course use further options to narrow it down, for example: 您当然可以使用更多选项来缩小范围,例如:

git log -Sfoobar --since=2008.1.1 --until=2009.1.1 -- path_containing_change

Isn't that awesomely useful? 这不是很有用吗?

How about git log --stat | grep 'filename' 怎么样的git log --stat | grep 'filename' git log --stat | grep 'filename' to begin narrowing it down? git log --stat | grep 'filename'开始缩小范围?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM