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

Popular posts from this blog

How to SSH to remote server without entering password each time.

How to redirect a URL in NGINX

Ruby on Rails Installation on Windows 7