Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search for a code change in all branches

Tags:

git

I'm looking for a commit which introduced a line of code with the word "Rental" somewhere in my project. How can I search all branches for the commits where lines were introduced that included that phrase?

like image 711
bgcode Avatar asked Dec 09 '11 02:12

bgcode


People also ask

How do I grep in all branches?

Here are three commands: git grep-branch - Search in all branches local & remote. git grep-branch-local - Search in local branches only. git grep-branch-remote - Remote branches only.

How can I see which files have been changed in a branch?

To get the list of files modified (and committed!) in the current branch you can use the shortest console command using standard git: git diff --name-only master... If your local "master" branch is outdated (behind the remote), add a remote name (assuming it is "origin"): git diff --name-only origin/master...

Does git grep search all branches?

Git includes a grep command to search through commits to a repo as well as the local files in the repo directory: git grep. Sometimes it is useful to search for a string throughout an entire repo, e.g. to find where an error message is produced.


1 Answers

git log --branches -S "Rental"

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

like image 185
dahlbyk Avatar answered Oct 01 '22 00:10

dahlbyk