当我做git branch时,我知道我在分支机构v0.2上.
git branch
v0.1
* v0.2
Run Code Online (Sandbox Code Playgroud)
但是,当我执行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
Run Code Online (Sandbox Code Playgroud)
最初我命名了这个分支v1.1,但现在我已经在本地和远程将其重命名为v0.2.
我怎样才能一劳永逸地解决这个问题.
Git跟踪哪个本地分支与哪个远程分支相关.当您重命名远程分支时,git 丢失了跟踪哪个远程v0.2分支与您的本地分支.您可以使用branch命令的--set-upstream-toor -u标志来解决此问题.
git checkout v0.2
git branch -u origin/v0.2
Run Code Online (Sandbox Code Playgroud)
现在,当你这样做时git push,git将知道你的本地v0.2配对的分支.