【问题标题】:push from local branch to different remote branch从本地分支推送到不同的远程分支
【发布时间】:2015-04-02 17:56:06
【问题描述】:

我在远程有 2 个名为 developerCurrent 的分支。在本地,我正在处理分支developer,并将我的更改推送到远程developer。问题是,如何从本地 developer 推送到远程 Current

我试过这些:

git push origin Current -f
// error:
// src refspec Current does not match any.
// failed to push some refs to ...

// and this one too:
git config push.default upstream
git push origin Current -f
// error: same as the first try

// and this one too:
git branch --set-upstream-to developer origin/Current
// or:
git branch --set-upstream-to developer Current
// error: fatal: branch 'Current' (or 'origin/Current') does not exist

【问题讨论】:

  • git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>] - 你的语法搞砸了。

标签: git branch git-branch remote-branch


【解决方案1】:

你可以这样做:

git push origin developer:current

这会将分支 developer 从本地仓库推送到远程仓库上的分支 current。如果您要覆盖当前分支上的更改,您还需要使用 -f 标志。

FWIW,执行git push origin :current(注意current 之前的:)将从远程删除分支current

【讨论】:

  • 仅供参考,这会将developer 推送到current,而不会使current 成为developer 的上游分支。 IE。如果developer 设置为跟踪origin/developer,则运行此命令不会改变它。就个人而言,这就是我一直在寻找的
【解决方案2】:

在您的developer 分支上,尝试git push -u origin Current-u 是简写 --set-upstream。看起来使用 --set-upstreamgit branch 需要上游分支已经存在;与git push 一起使用时不是这种情况。

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 2018-10-02
    • 1970-01-01
    • 2021-09-13
    • 2016-10-25
    • 2012-03-30
    • 2018-02-12
    • 1970-01-01
    • 2021-07-14
    相关资源
    最近更新 更多