繁体   English   中英

git 推送到新的上游分支

[英]git push to a new upstream branch

我有一个与我想推送到的 repo 没有关联的 repo。 审核后,我们准备在工作中提交以供评论。

首先,我添加了我想将其推送到的上游仓库:

git remote add upstream git@ssh.dev.azure.com:v3/place/projectgroup/repo

这是第一个也是唯一一个添加的上游,和以前一样,它只存在于我的 Mac 上。 然后我尝试添加上游:

$ git branch --set-upstream-to origin/candidate/1.0
error: the requested upstream branch 'origin/candidate/1.0' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
$ git push -u origin/candidate/1.0 HEAD
fatal: 'origin/candidate/1.0' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我的问题是,如何使用尚不存在的上游名称将当前分支推送到远程仓库?

假设您在分支mybranch上。 然后你说

git push -u upstream mybranch

这意味着:“获取我的本地mybranch ,将其推送到upstream远程(它也将被称为mybranch ),同时,给我一个跟踪分支,它将充当本地mybranch和远程之间的链接mybranch 。”

如果您希望远程名称与本地名称不同,请使用冒号语法,例如mybranch:remotebranch (您实际上可能不得不说mybranch:refs/heads/remotebranch ,我对此有点困惑。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM