mfaani
mfaani

Reputation: 36317

Xcode gives error upon checkout: The branch could not be created because one named “master” already exists

In Xcocde's source navigator, I've selected a branch then right click and hit checkout. Yet I get the following error:

enter image description here

The branch could not be created because one named “master” already exists.

Upvotes: 2

Views: 1283

Answers (1)

mfaani
mfaani

Reputation: 36317

I was getting this error message because I've selected a branch under the Remotes group and was trying to checkout out to that branch.

I suppose when you checkout a remote branch that doesn't have a local branch with that name, then git will attempt to create that branch. For more see here. But since I already had that branch created it was failing.

There is nothing wrong with trying to create a local branch off a fetched branch, but that was just not what I wanted to do. I just wanted to checkout to an existing branch.

So all I had to do was:

Xcode >> Source control navigator >> Branches >> select branch and checkout.

I was previously doing:

Xcode >> Source control navigator >> Remotes >> select branch and checkout.

And for the above mentioned reason it was failing.

Upvotes: 3

Related Questions