Skip to content

Instantly share code, notes, and snippets.

@ex-nerd
Created August 24, 2023 08:41
Show Gist options
  • Save ex-nerd/343a603b526da7fcb24acab1a2f51b64 to your computer and use it in GitHub Desktop.
Save ex-nerd/343a603b526da7fcb24acab1a2f51b64 to your computer and use it in GitHub Desktop.
Given a file path, it lists all remote branches that have modified that path
#
# I needed this for something and was surprised that I couldn't find an easy answer elsewhere.
# So here it is just in case a search engine picks it up.
#
# Given a file path, it lists all remote branches that have modified that path
#
function git_file_branches() {
echo -e "date\tbranch\tauthor"
for BRANCH in $(git log --remotes --no-merges --not develop --source --decorate=short -- $1 | grep ^commit | cut -f 2 | uniq); do
git log -1 --date=format-local:'%Y-%m-%d %H:%M:%S' --pretty=format:"%ad%x09%D%x09%an <%ae>" $BRANCH 2>/dev/null | sort
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment