Git Clean remote branches

  • Language:: Bash

  • Type:: Source Code Management

  • Context:: cleans up branches that have already been merged into the branch you are currently on.

  • Description

  • Snippet

 
$ git branch -r --merged | egrep -v "(^\*|main|phase-2|phase-2-develop)" | xargs -n 1 git push --delete origin
 
# remove the origin prefix of the branch
$ git branch -r --merged | egrep -v "(^\*|main|phase-2|phase-2-develop)" | sed 's/origin\///' | xargs -n 1 git push --delete origin
 

📇Additional Metadata