DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Search String Pattern in Git History


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



Published

Oct 15, 2015

Last Updated

Jan 18, 2019

Category

Tech

Tags

  • git 36
  • history 3
  • search 7

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor