Reputation: 100000
I swear I wrote a test called "heartbeatTest" or "heartbeatRouteTest" in one of the branches of a Git repository.
But I can't find it in any of the branches. Is there a way to do a global search with Git to find a matching phrase in any branch for a particular local/remote repository?
Upvotes: 3
Views: 1927
Reputation: 25383
Check out Git grep
git grep heartbeat $(git rev-list --all)
You could be a little more specific with:
git grep heartbeat.*Test $(git rev-list --all)
Here is a nice article with more examples of using Git grep: Search a Git repository like a ninja
Upvotes: 1
Reputation: 60255
You want
git log -G"$regex" --all
or
git log -S"string" --all
which search all current history for commits that change lines (-G
) or change the number of lines (-S
) containing a match. There are plenty of options to alter git log
's selection of starting points to walk through history.
Upvotes: 2