views:

267

answers:

2

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?

+4  A: 

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

opsb
See answer below for info about the -m flag
opsb
+2  A: 

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.
...
Pat Notz
I had noticed these "plumbing" commands as I was searching for a solution to this problem. Very useful to know that parameters get passed down to these lower commands. I'll know to drill down in future. This seems to be a theme with git, there is a surface layer that you can use to get stuff done, but without knowing the plumbing layer you can easily become unstuck.
opsb