How can I search all of my Git remote branches for the commit where a specific line or two of code were added (not just a file, but contents within them)?
My repos are all on github.
How can I search all of my Git remote branches for the commit where a specific line or two of code were added (not just a file, but contents within them)?
My repos are all on github.
Does git blame
suit your needs? You can run it on a specific revision (irrelevant to whether it's on the remote or not, see How to 'git blame' on the remote-side repository?).
For example:
$ git blame master file_in_question.c
$ git blame 20f89e16 file_in_question.c
Also, if your repositories are on GitHub, you can use their interface to git blame
if you'd prefer. See "Using git blame to trace changes in a file"
In addition to using git blame
, you can also search in local branches with
git log -S<search-string> --source --all
It may search your local remote-tracking branches too, but I'm not sure. You could always just make a local branch of your remote ones, of course. See git: finding a commit that introduced a string for more details.
There's also a regex version that you could use (see git log
docs):
-G<regex>
Look for differences whose added or removed line matches the given
<regex>
.