How to delete a branch in Git

Sometimes Xcode gets confused with the intricacies of versioning. Frequently I find that I’m on a branch, everything is working fine, and for the life of me can’t merge it back into the Master branch. Often this happens because Xcode refuses NOT to make an change, such as update certain files I have already dealt with in the new branch.

That’s when the command line git tool can come in handy.

Suppose my new branch Mavericks is what I’d like to merge into master, but both Xcode and GitHub hang when trying to do so, citing “unrelolvable conflicts” and weird error messages. Rather than trying to understand them, it’s probably easier to just DELETE master and create a new copy from my Mavericks branch. Let’s do this.

First display what we have – cd into your working directory first, then issue

OK, we’re on the Mavericks branch, and master also exists. Let’s delete master:

Done and dusted – master is history. Let’s create a copy and call it master, then check it out:

Nice – looks like we’re all set here. You can also combine the “branch + checkout” command by typing “git checkout -b master”

Back in Xcode (and GitHub) everything seems fine too.

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at and

Add your voice!