Skip to content

Instantly share code, notes, and snippets.

@jobwat
Created February 14, 2024 00:06
Show Gist options
  • Save jobwat/887e9f1c30f34bc45a4cedca4a013e30 to your computer and use it in GitHub Desktop.
Save jobwat/887e9f1c30f34bc45a4cedca4a013e30 to your computer and use it in GitHub Desktop.
list the remote branches with last commit authored by yourself
git branch -r | cut -d '/' -f 2- | grep -v '\->' | sort -u | while read branch; do [[ "$(git --no-pager log -n 1 --format='%ae' "origin/$branch" 2>/dev/null)" == "$(git config user.email)" ]] && echo $branch; done
@danielhseabrook
Copy link

suggestion:

git remote prune origin && git branch -r | cut -d '/' -f 2- | grep -v '\->' | sort -u | while read branch; do [[ "$(git --no-pager log -n 1 --format='%ae' "origin/$branch" 2>/dev/null)" == "$(git config user.email)" ]] && echo $branch; done

Addting git remote prune to the start clears any branches from the local repo that have been deleted on the remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment