How to delete a branch in GIT ?
- git branch -D branch_name (This removes the branch from our local)
- git push origin :branch_name (Branch is removed from our git repo.)
Bulk delete branches in GIT
- git branch -r | grep -Eo 'feature/.*' | xargs -I {} git push origin :{}
- This will delete all branches starting with feature/
After deleting all the branches from GIT. To delete the branches locally run the following.
- git branch | grep -Eo 'feature/.*' | xargs -I {} git branch -D {}
or
- git remote update --prune
Comments
Post a Comment