Skip to content

Instantly share code, notes, and snippets.

@ricventu
Last active March 20, 2023 08:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricventu/3a39b8a9748d05a70e6f2fa620436b2b to your computer and use it in GitHub Desktop.
Save ricventu/3a39b8a9748d05a70e6f2fa620436b2b to your computer and use it in GitHub Desktop.
Git prune merged branches

Delete local merged branches

  git branch --merged | grep -v  "master\|main\|develop" | sed 's/origin\///' | xargs git branch -d 

Delete remote merged branches

  git branch -r --merged | grep -v  "master\|main\|develop" | sed 's/origin\///' | xargs -n 1 git push -d origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment