Reputation: 83517
I'm working on one particular branch in my git repo and notice a piece of code that I thought I changed. Perhaps the change is on another branch that hasn't been merged into master
or the current branch on which I am working. How do I search the whole repository, including all branches, for a particular change to one source code file?
Upvotes: 3
Views: 811
Reputation: 1323115
You can try and use the pickaxe (-S
) or regexp (-G
) options of git log
.
git log --all -Schange -- path/to/change
(replace change by a keyword you know is representing your particular change)
See "How to grep (search) committed code in the git history?"
As I mentioned:
this looks for differences that introduce or remove an instance of
<string>
.
It usually means "revisions where you added or removed line with 'change
'".
Add the --all
in order to search in all branches.
To get the branch(es) those commits are part on, you can use:
git branch --contains SHA1
(as I mentioned in "How to list branches that contain a given commit?")
Upvotes: 6