如何使用git log pickaxe显示更改本身? [英] How to show the change itself using git log pickaxe?

查看:65
本文介绍了如何使用git log pickaxe显示更改本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在git log中搜索特定的字符串,以查找在何处对其进行了修改/删除/添加.

I would like to search git log for a specific string to find where it was modified/deleted/added.

我知道我可以使用 pickaxe (即 git log -S"Text" )

I knew that I can do this using pickaxe (i.e., git log -S"Text")

当我运行此命令时,仅显示发生更改的提交的名称.我还尝试了 git log -G"Text" ,但没有区别.

When I run this command, only the names of the commits where the change has occurred are shown. I also tried git log -G"Text" but no difference.

当我尝试 git log -p -S"Text" 时,它显示了两个版本的文件之间的完全对比.

When I tried git log -p -S"Text", it showed me full comparision between two versions of files.

是否可以找到更改/添加/删除文字的确切位置(行)?

Is there a way to spot the exact location (line) where the text has been changed/added/deleted?

我检查了相关帖子 2 ,但没有回答我问题.我正在使用Windows操作系统.

I checked related posts 1, 2 but didn't answer my question. I'm working on Windows OS.

推荐答案

Git不提供内置方法来执行此操作,但是您可以使用寻呼机的功能来查找文本.例如,如果使用较少,则可以运行 git log -p -G"Text" .然后,您可以通过键入/Text 在此命令的输出中搜索文本".到目前为止,这是找到所需内容的最简单方法.

Git doesn't provide a built-in way to do this, but you could use the capabilities of your pager to find the text. For example, if you're using less, you can run git log -p -G"Text". Then you can search for "Text" in the output of this command by typing /Text. This is by far the easiest way to find what you're looking for.

有另一种相当丑陋的方式可以满足您的需要.如果您使用-word-diff-regex = Text ,则Git将生成另一种word-diff格式,该格式将从一个文本"实例突出显示到另一个实例,或者仅突出显示一个实例.一个存在.同样,使用您的传呼机将变得更好,更容易阅读.

There is an alternative, rather ugly way to hack around this which might meet your needs. If you use --word-diff-regex=Text, Git will produce an alternative word-diff format which will highlight from one instance of "Text" to the next, or just the single instance if only one exists. Again, using your pager is going to be a lot nicer and easier to read.

这篇关于如何使用git log pickaxe显示更改本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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