List commits where the patterns changes
git log -p --all -G 'pattern'
: search a string in git history.
-G
search for all editing activity with "pattern",
while -S
only search for creation and removal of "pattern",
the results of -S
is the subset of results of -G
.
When the "pattern" is in the current commit,
there will be only 1 result of -S
,
where the pattern is added into the texts.
When the "pattern" is removed in current commit,
there will be 2 results of -S
:
the first (which is newer) is where the pattern is removed,
the second is where the pattern is added.
-p
denotes --patch
, which will print the editing details.
If you only want to know the commit name which deal with the "pattern",
omit this option.
--all
search in all branches.
List all the commits where pattern exists
git rev-list --all | xargs git grep moveImage
The oldest commit(last line of the output) in git log ...
is the same
with the oldest commit in git rev-list...
.
The newest commit in git log ...
is the child of the newest commit
in git rev-list ...
.
Ref:
Search all of Git history for a string?
Git history - find lost line by keyword