0

I am looking for a git command which would allow me to find all of the commits where a specific string was added.

The string could also be a regular expression, and I also want to retrieve the specific string in the commit that matches that expression.

Example -

I would like to find all the commits where the pattern - // FIX - BUG-XXXX was added to the files. Including matching lines such as: // FIX - BUG-1234 and // FIX - BUG-2345 etc.

Alfie J. Palmer
  • 827
  • 2
  • 15
  • 30
  • I dont think there's any direct git way of doing this. You can create a shell script which does `git log` (get commits) `- > git show` (check what happened in commit) `- > grep` (check for regex ++.*)... Somewhere around these lines... – Vishwanath Mar 06 '15 at 17:02

1 Answers1

0

To my knowledge, there isn't a particular way to check through files for a specific string easily.

My guess is you want git-blame.

For the file that you are wanting to figure out who made the changes, you would run something like:

main.cs

$ git blame -L 40,60 main.cs

This would search lines 40-60 in main.cs for any changes, and report them back to you.

Ryen Nelsen
  • 367
  • 1
  • 9