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?
It shows all the changes made to the merged branch as a result of the merge. Show activity on this post. git show -c c0f501 will display a combined diff from commit c0f501 to both of its parents, as printed by git diff during a merge. This gives a better overview than git show -m .
A merge takes two or more branches, and creates a commit that interleaves the changes in all parents (resolving conflicts, as needed; the user has to decide how). git does not change history by itself.
I'll start by showing how the default “chronological” order of git log can mislead you when the history contains merge commits. Then I'll show how you can visualize Git merge history using git log --graph , and how to see the “true” history of a single branch using --first-parent .
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
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. ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With