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?
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.
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...
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.
git log --branches -S "Rental"
You can also use --all
instead of --branches
, which will include tags, remote branches and your first stash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With