Perform a full text search in Git committed code...

Sometimes, you remember a change that you have done in sources, and you need to find the commit that introduce this change...

Solution :

Use the pickaxe option of git log like this :

git log -S <searched string>

Tips :

  • Searched string can be embedded in quotes...
  • -S will look for occurences in the sources... ('-S' official help)
  • -S can be replaced by -G, this will search look for differences in added or removed lines that match ('-G' official help)

This command will give you up the commit's metadata.
To get a source's diff that contains the searched string, add -p to the command like :

git log -S <searched string> -p 

Enjoy

 

Comments are closed