EricC
EricC

Reputation: 5870

I did git branch some-remote-branch by mistake

I wanted to change branch to an existing remote branch, but by mistake I did git branch some-remote-branch which creates a new local branch.

How to can I fix this?

Upvotes: 0

Views: 85

Answers (2)

Supun Wijerathne
Supun Wijerathne

Reputation: 12938

There's nothing to fix there. Just

git checkout correct-branch

This will create a local branch named correct-branch same as origin/correct-branch and you will be switched into that.

No need to delete the branch some-other-branch you created locally.

Upvotes: 1

Grinch91
Grinch91

Reputation: 952

Delete the new local branch and then checkout to the correct remote branch.

git branch --delete some-remote-branch
git fetch (if your repo doesn't have the remote branch already)
git checkout -t origin/correct-branch

Upvotes: 1

Related Questions