2

I have managed to find a resource to search for "a" string in all commits (link below). But I do not know how to do the same command and have the specific files within the commits be listed (which added or lost that string).

All commits would be good but ideally I'd also like to get a list of files that added or lost that string within a specific commit. How would I do this for all or a specific commit?

Finding a Git commit that introduced a string in any branch

Community
  • 1
  • 1
Oliver Williams
  • 5,966
  • 7
  • 36
  • 78

1 Answers1

1

You can get the log of a specific commit with:

git log -1 <aSHA1>

So add your pickaxe search to that:

git log --name-only -1 -S "<whatever>" <aSHA1>
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • both methods only give me the commit sha1, the author, and the date. No file or line data, sorry. – Oliver Williams Jan 09 '17 at 20:36
  • @OliverWilliams I have added the --name-only option for listing files (but not lines) – VonC Jan 09 '17 at 20:40
  • - however, and this is not the question I've asked, running the command shown on github doesn't seem to remove the sensitive data as I wished: https://help.github.com/articles/remove-sensitive-data/ – Oliver Williams Jan 09 '17 at 21:04
  • @OliverWilliams Indeed: could you ask a new question for that? (I have to go, but I will review it later) – VonC Jan 09 '17 at 21:05