How to Delete a Git branch both locally and on remote?

To delete local branch :

$ git branch -d branch_name

To delete local branch Forcefully :

$ git branch -D branch_name

Here -D is an alias for – -delete – -force, which deletes the branch irrespective of its merged status.
To delete remote branch :

$ git push origin --delete branch_name

Or

$ git push origin : branch_name

After the branch is deleted on both remote and on local machine run following command on all machine to propagate changes made

git fetch --all --prune
A pat on the back !!

Leave a Reply

Your email address will not be published. Required fields are marked *