如何搜索git历史记录以查找消失的行? [英] How do I search git history for a disappeared line?

查看:193
本文介绍了如何搜索git历史记录以查找消失的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在git存储库中搜索特定文件的历史记录来查找一条消失的行。提交消息不会有任何相关的文本进行搜索。我使用了什么命令?



更多详细信息:这是我的非星级任务跟踪软件中的待办事项列表的历史记录。我一直保持两年,因为软件中没有足够的信息。不幸的是,我的提交消息通常只有任务ID,我需要做的是按主题查找封闭任务,而不是按编号查找。是的,真正的解决方案是更好的任务跟踪软件,但这完全是我的手。 解决方案

扒手!



从git-log手册页:



$ b

查找引入或删除< string>实例的差异。 。请注意,这与简单出现在diff输出中的字符串不同。请参阅gitdiffcore(7)中的pickaxe条目以获得更多详细信息。


例如,您当然可以使用更多选项来缩小范围:

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

这不是很有用吗?


I need to search the history of a specific file in a git repository to find a line that is gone. 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. 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. 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:

-S<string>

Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.

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?

这篇关于如何搜索git历史记录以查找消失的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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