Reputation: 1468
When I do git branch I get that I am on branch v0.2.
git branch
v0.1
* v0.2
But when I do git push it says "The upstream branch of your current branch does not match the name of your current branch "
git push
fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use
git push origin HEAD:v1.1
To push to the branch of the same name on the remote, use
git push origin v0.2
Initially I had named this branch v1.1 but now I have renamed it to v0.2 locally and remotely.
How can I fix this once and for all.
Upvotes: 10
Views: 10615
Reputation: 5643
Git keeps track of which local branch goes with which remote branch. When you renamed the remote branch, git lost track of which remote goes with your local v0.2
branch. You can fix this using the --set-upstream-to
or -u
flag for the branch command.
git checkout v0.2
git branch -u origin/v0.2
Now when you do git push
, git will know which branch your local v0.2
is paired with.
Upvotes: 15
Reputation: 224942
You may have renamed the branch both locally and remotely, but the local branch’s upstream appears to still point to the old name. You can verify this by doing a
$ git branch -vv
…
* v0.2 01234abc [origin/v1.1]: Some message
… where, if it indeed says origin/v1.1
in square brackets, your upstream needs to be changed. It should be as easy as specifying the -u
flag when pushing, though:
git push -u origin v0.2
Upvotes: 2