Git Push & Delete Remote Branches

Git Push & Delete Remote Branches

We all know that after we have finished with a certain feature branch in git, we can remove it easily by running the following command in shell:

git branch -d feature/branch-name

However, this only deletes this specific feature branch locally on your machine, and it does not remove the one sits on the server. To delete the feature branch on the remote server, the syntax is a bit odd, but you will get used to it:

git push origin :feature/branch-name

That is, you still use “push” command, even though you are deleting it. And this command works with the “branch -d” command independently, so you need to run those two commands to remove both local and remote branches.


Leave a Reply

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

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!