Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git log -S does not show anything

Tags:

git

git-log

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??

like image 945
Tom Esterez Avatar asked Oct 26 '25 12:10

Tom Esterez


1 Answers

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.

like image 112
Joseph K. Strauss Avatar answered Oct 28 '25 02:10

Joseph K. Strauss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!