How to delete a branch in Git

Posted: 5 December 2012 in Git, Uncategorized, Version Control

First you delete the branch locally and then you delete the branch in the origin.

git branch -d branchName # discard locally, must be fully merged
git push origin :<branchName> # replicate the change in the remote repository

You may want to discard your changes made within the branch. the -D option is used then.

git branch -D branchName # delete the branch, irrespective of the merge status
git push origin :<branchName> # replicate the change in the remote repository
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s