在 git 历史记录中搜索合并提交中的更改

发布于 2024-08-09 08:17:00 字数 132 浏览 5 评论 0原文

要搜索已在 git 历史记录中添加/删除的字符串,我可以执行

git log -S'some text'

此操作,效果很好,只是它不搜索合并提交。如何获取在搜索中包含合并提交的命令?

To search for a string that has been added/removed in git history I can do

git log -S'some text'

This works great except that it doesn't search through merge commits. How do I get the command to include merge commits in the search?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

囍孤女 2024-08-16 08:17:00

看来 -m 标志给了我想要的结果,

git log -m -S'some text'

我在另一个网站上找到了这个,如果有人能指出我包含此标志的手册页的方向,那就太好了。这个不包含它 http://ftp。 kernel.org/pub/software/scm/git/docs/git-log.html

it appears that the -m flag gives me the desired result

git log -m -S'some text'

I found this on another site, if someone could point me in the direction of a man page that includes this flag that would be great. This one doesn't include it http://ftp.kernel.org/pub/software/scm/git/docs/git-log.html

违心° 2024-08-16 08:17:00

由于某些 Git 命令是构建在其他(“管道”)命令之上的,因此它们通常会继承其他命令的选项。我同意,看不到手册页或 --help 输出中记录的内容是很烦人的。在这种情况下,git-log 帮助状态:

该命令采用适用的选项
到 git-rev-list 命令来控制
显示什么、如何显示以及选项
适用于 git-diff-* 命令
控制每次提交更改的方式
显示介绍。

在这种情况下,您将在 git-diff-tree

...
-m
    By default, git-diff-tree --stdin does not show differences 
    for merge commits. With this flag, it shows differences to 
    that commit from all of its parents. See also -c.
...

Since some Git commands are built on top of other ("plumbing") commands they often inherit options from other commands. I agree that it's annoying not to see those documented in the man pages or in the --help output. In this case, the git-log help states:

The command takes options applicable
to the git-rev-list command to control
what is shown and how, and options
applicable to the git-diff-* commands
to control how the changes each commit
introduces are shown.

In this case, you'll find the -m option under git-diff-tree:

...
-m
    By default, git-diff-tree --stdin does not show differences 
    for merge commits. With this flag, it shows differences to 
    that commit from all of its parents. See also -c.
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文