4

Is there a way to search all branches/all their versions for some string? Essentially the equivalent of doing ctrl+shift+f to search the entire solution...but for all versions and branches?

Longshot, but figured I would ask. If not, is there at least something for file name? Asking about github.com, but if it's in gitshell, that's cool too.

My dear friends decided to delete some code at some point in a branch that wasn't merged.

VSO
  • 11,546
  • 25
  • 99
  • 187
  • possible duplicate of [Search all of Git history for a string?](http://stackoverflow.com/questions/4468361/search-all-of-git-history-for-a-string) – djechlin Jul 14 '15 at 18:50

1 Answers1

5

While this would be using Git instead of GitHub's web interface, how about something like this?

git log --all --source -S"Some string"

There is also a -G option that does regex instead of -S. The details are there if you do a

man git log

The only negative here is that it assumes you've already cloned the repository.

kotakotakota
  • 731
  • 8
  • 26
  • 1
    Thank you, I won't have a chance to try this for a few hours, but I will come back to accept the answer when I do. – VSO Jul 14 '15 at 18:45
  • 2
    Note that this only shows you which commits have added or removed that string. If you add the -p flag, it will also show you the entire commits. Depending on how large the commits are, you may be better off using the -p flag and then searching within that. Hope it works out for you :) – kotakotakota Jul 14 '15 at 18:53
  • 1
    Just wanted to say I appreciate it again. I found what I needed just now (didn't have a chance to work on it until today) and it might save me a ton of time. – VSO Jul 19 '15 at 06:29
  • Glad to hear! :D Thanks for letting me know; left me with a great feeling to round off the day knowing I was able to help :) – kotakotakota Jul 19 '15 at 06:39