Once you are done working on a remote branch i.e., you and your collaborators have finished a feature and merged it into your remote’s master branch or whichever branch that suits the job. Using the
--delete option to
git push, you can delete a remote branch.
The syntax of the commands is as follows. Use any one the command depending on the Git Version you use.
git push origin :<branch> # Git versions that are older than 1.7.0 git push origin -d <branch> # Alias used in the Shorter version (Git 1.7.0 or newer) git push origin --delete <branch> # Git version 1.7.0 or newer
Example : Suppose if you want to remove the branch called
nav-bar from the remote server, then run:
git push origin --delete nav-bar
Note : Essentially, this removes the pointer from the server. The Git server will generally save the data until a trash collection occurs, so if it was accidentally destroyed, it is often simple to restore.