Skip to content

Instantly share code, notes, and snippets.

@drmingdrmer
Last active October 7, 2015 05:57
Show Gist options
  • Save drmingdrmer/3116181 to your computer and use it in GitHub Desktop.
Save drmingdrmer/3116181 to your computer and use it in GitHub Desktop.
shell script to find out in which git-branch the last time a file was modified
# usage:
# ./git-file-branch.sh fn.cpp
prev=$(git rev-parse $(git rev-list -n1 --all -- $1)^)
for br in $(git branch -a | cut -c 3-); do
[ "x$(git rev-list -n1 --no-merges --first-parent $prev..$br -- $1)" != "x" ] && echo $br
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment