Skip to content

Instantly share code, notes, and snippets.

View ex-nerd's full-sized avatar

Chris Petersen ex-nerd

View GitHub Profile
@ex-nerd
ex-nerd / git_file_branches.sh
Created August 24, 2023 08:41
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