Search for code changes in all branches

I am looking for a commit that introduced a line of code with the word "Rent" somewhere in my project. How can I search all branches for commits where lines containing this phrase were entered?

+4
source share
3 answers
git log --branches -S "Rental" 

You can also use --all instead of --branches , which will include tags, remote branches, and your first stash.

+12
source

Since you are looking for the “first time” when something is being introduced, you can try using git bisect instead . He walks you through setting the point “it's not here” and “it's definitely here,” and then displays the various commits (asking “is this here?”) Until he isolates where he is.

It is also not blindly going through the story linearly, but rather "bisecting" the tree, as if you were looking for a binary tree.

It is slightly slower than grep for the whole story, but more useful for a general attempt to track the “first time” of anything else; The main use case is "when the first time this error could occur."

Then it would be wise to see which branches include this commit using git branch --contains <commit> .

+2
source

Try the following:

 git log -Srental --all --pretty=oneline 
+1
source

Source: https://habr.com/ru/post/1385454/


All Articles