Skip to content

Instantly share code, notes, and snippets.

@ba55ie
Created January 15, 2021 09:37
Show Gist options
  • Save ba55ie/7fa073d7b83568d7d30553500599c101 to your computer and use it in GitHub Desktop.
Save ba55ie/7fa073d7b83568d7d30553500599c101 to your computer and use it in GitHub Desktop.
Git - Remove local branches that have been deleted on remote

Remove local branches that have been deleted on remote

Add the following command to [alias] section in your .gitconfig.

[alias]
  yolo = "!f() { git remote prune origin; git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -D; }; f"

Merged

If you only want to delete branches that have been merged into the current branch, use git branch -d (lowercase -d).

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