ripper234
ripper234

Reputation: 230028

I accidentally created a local branch named origin/foo. Now what?

I have a remote branch named foo, that is not tracked in the current client.

I did git checkout -b origin/foo, and this created a local branch named origin/foo. This looks bad, since up until now all my local branches didn't have a origin/ prefix.

I tried to delete this local branch by running git branch -d origin/foo, but it complained that the branch is not fully merged. I'm afraid that if I'll force it using -D, it will actually delete the remote branch.

How do I clean up this mess?

Upvotes: 29

Views: 9131

Answers (2)

ripper234
ripper234

Reputation: 230028

Resolved by renaming the branch and then deleting it.

git branch -m origin/foo bad_foo
git branch -d bad_foo

Upvotes: 37

Chris B
Chris B

Reputation: 41

ripper234's answer is correct however for those who might overlook the missing "git", it's:

git branch -m origin/foo bad_foo
git branch -d bad_foo

I would've commented but don't have enough "reputation" to comment yet

Upvotes: 4

Related Questions