Git历史记录 - 按关键字查找丢失的行 [英] Git history - find lost line by keyword

查看:87
本文介绍了Git历史记录 - 按关键字查找丢失的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果有任何方法可以找到它的修订版本号,那么它在哪里是最后一次没有购买FishEye?

解决方案

这可以通过解决( -S )选项 gitlog

  git log -SFoo  -  path_containing_change 

(您甚至可以添加时间范围: - since = 2009.1.1 --until = 2010.1.1 )

  -S< string> 




寻找引入或移除<$ c $的实例c>< string>

请注意,这与简单出现在diff输出中的字符串不同。请参阅 gitdiffcore(7)中的镐符条目以了解更多详情。




  diffcore-pickaxe 




此变换用于查找表示触及指定字符串的变化的文件对。

diffcore-pickaxe 正在使用中,它检查是否有文件对的原始端具有指定的字符串,而其结果端没有。

这样的一个filepair表示出现在这个变更集中的字符串。

它还检查丢失指定字符串的相反情况。






2014年更新:

从那以后,您可以做到(从nilbus 回答):

  git log -p --all -S'搜索字符串'
git log -p --all -G'匹配正则表达式'




这些日志命令列出提交,添加或删除给定的搜索字符串/正则表达式,(通常)最近的第一个。

-p - patch )选项会导致相关差异显示在添加或删除模式的位置,因此您可以在上下文中看到它。



找到了一个相关的提交,添加了您正在查找的文本(例如。 8beeff00d ),找到包含提交的分支:



  git branch -a --contains 8beeff00d 

如何列出包含给定提交的分支?


I had somewhere in my Git repository a line containing word "Foo" a couple hundreds commits before.

If there is any way to find its revision number where it was the last time without buying FishEye?

解决方案

That may be addressed by the pickaxe (-S) option of gitlog

 git log -SFoo -- path_containing_change

(you can even add a time range: --since=2009.1.1 --until=2010.1.1)

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

diffcore-pickaxe

This transformation is used to find filepairs that represent changes that touch a specified string.
When diffcore-pickaxe is in use, it checks if there are filepairs whose "original" side has the specified string and whose "result" side does not.
Such a filepair represents "the string appeared in this changeset".
It also checks for the opposite case that loses the specified string.


Update 2014:

Since then, you can do (from nilbus's answer):

git log -p --all -S 'search string'
git log -p --all -G 'match regular expression'

These log commands list commits that add or remove the given search string/regex, (generally) more recent first.
The -p (--patch) option causes the relevant diff to be shown where the pattern was added or removed, so you can see it in context.

Having found a relevant commit that adds the text you were looking for (eg. 8beeff00d), find the branches that contain the commit:

git branch -a --contains 8beeff00d

(I reference that last command in "How to list branches that contain a given commit?")

这篇关于Git历史记录 - 按关键字查找丢失的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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