gpt4 book ai didi

git - 本地和远程分支名称相同仍然得到 "The upstream branch of your current branch does not match the name of your current branch "

转载 作者:太空狗 更新时间:2023-10-29 13:32:24 30 4
gpt4 key购买 nike

当我执行 git branch 时,我知道我在分支 v0.2 上。

 git branch
v0.1
* v0.2

但是当我执行 git push 时它说“你当前分支的上游分支与你当前分支的名称不匹配”

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

最初我将该分支命名为 v1.1,但现在我在本地和远程将其重命名为 v0.2。

我怎样才能一劳永逸地解决这个问题。

最佳答案

Git 跟踪哪个本地分支与哪个远程分支。当您重命名远程分支时,git lost track 哪个远程与您的本地 v0.2 分支一致。您可以使用分支命令的 --set-upstream-to-u 标志来解决此问题。

git checkout v0.2
git branch -u origin/v0.2

现在,当您执行 git push 时,git 会知道您的本地 v0.2 与哪个分支配对。

关于git - 本地和远程分支名称相同仍然得到 "The upstream branch of your current branch does not match the name of your current branch ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27257761/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com