Reputation: 5870
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
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
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