Skip to content

Instantly share code, notes, and snippets.

@naiduv
Last active June 25, 2019 13:28
Show Gist options
  • Select an option

  • Save naiduv/0a88cc577c253aca3ddb648d81b1f3aa to your computer and use it in GitHub Desktop.

Select an option

Save naiduv/0a88cc577c253aca3ddb648d81b1f3aa to your computer and use it in GitHub Desktop.
git diff all local branches for a line in a file
#searches all local branches
git branch | cut -d" " -f 3 | grep -Ev "^$" | while read line; do git diff $line <replace_with_file_path>; done | grep <replace_with_search_string>
#example:
#search diffs in all branches in the packages.json file (at the root of current directory) for the term "debug"
git branch | cut -d" " -f 3 | grep -Ev "^$" | while read line; do git diff $line package.json; done | grep debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment