Saturday, July 8, 2017

Delete a Git branch both locally and remotely

Official Synopsis
$ git push origin --delete <branch_name>
$ git branch -d <branch_name>

If there are unmerged changes which you are confident of deleting:
$ git branch -D <branch_name>

Delete Local Branch



To delete the local branch use:
$ git branch -d branch_name

Note: The - d alternative is a moniker for - erase, which just erases the branch in the event that it has just been completely converged in its upstream branch. You could likewise utilize - D, which is a false name for - erase - drive, which erases the branch "regardless of its blended status." [Source: man git-branch]

Delete Remote Branch 

As of Git v1.7.0, you can delete a remote branch using
$ git push origin --delete <branch_name>
which might be easier to remember than
$ git push origin :<branch_name>
which was added in Git v1.5.0 "to delete a remote branch or a tag."

In this way, the form of Git you have introduced will manage whether you have to utilize the less demanding or harder sentence structure.

Other links you may like 

1 comment:

  1. Very great post. I simply stumbled upon your blog and wanted to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing on your feed and I am hoping you write again very soon!

    ReplyDelete