fatal: The upstream branch of your current branch does not match the name of your current branch
阿新 • • 發佈:2021-08-19
fatal: The upstream branch of your current branch does not match the name of your current branch
問題
After doing a checkout of the remote branch releases/rel_5.4.1
using the Git GUI, I'm seeing this unexpected error message when I try to 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:releases/rel_5.4.1 To push to the branch of the same name on the remote, use git push origin rel_5.4.1
I don't know what Git is talking about. I probably want to push to origin releases/rel_5.4.1
since that's the branch which I checked out. So neither option seems correct to me.
git status
says I'm on branch rel_5.4.1
.
Here is the branch as it appears in my .git/config
:
[branch "rel_5.4.1"] remote = origin merge = refs/heads/releases/rel_5.4.1
What is going on?
回答
To allow to push to the tracking branch on a per-git basis, thus make git pull
and git push
symmetric, use
git config push.default upstream
Note: To globally set this for all of your git
s, use git config --global push.default upstream
However it is probably better to leave it to git config --global push.default simple