Skip to content

Instantly share code, notes, and snippets.

@get-data-
Created June 27, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save get-data-/b3aa18b09ec6433115a8dd161a1bc685 to your computer and use it in GitHub Desktop.
Save get-data-/b3aa18b09ec6433115a8dd161a1bc685 to your computer and use it in GitHub Desktop.
Clean up local branches after they are deleted on remote
# Look at what will get removed before taking action
git remote prune origin --dry-run
# Prune and delete those branches locally which were deleted on your remote repository
git fetch --prune
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment