Reputation: 22137
I've used git log -S
many times with great success but this time, it does not show anything.
I'm looking for the commit that introduced pagesNum
.
Here is what I do:
$ git status
On branch master
nothing to commit, working directory clean
$ git grep pagesNum
resources/locales/en.json: "search-page": "{pagesNum} Select...",
$ git log -SpagesNum
$ git log -S"pagesNum"
$ git log -S"pagesNum" --all
$
How is it possible that git log
does not show anything??
Upvotes: 4
Views: 275
Reputation: 4903
Apparently, -S
does not consider text that was introduced in a merge commit.
I just tested this by committing and empty commit, and then merging it, but adding a change. Doing this causes git grep
to find the text, but git log -S
shows nothing.
As a remedy, try the -m
option with git log
which considers the diff to all parents, although you will probably also want to add the --first-parent
option to only consider the diff to the main parent. However, --first-parent
will only show the merge commit that introduced the change, and not the regular commit, if applicable. Unfortunately, there is no way to modify the -m
option to show only the first parent without having that option apply to the selection of commits as well.
Upvotes: 3