git - 从本地分支推送到不同的远程分支

标签 git branch git-branch remote-branch

我在远程有 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 push origin developer:current

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

FWIW,执行 git push origin :current(注意 current 之前的 :)将删除分支 current 来自 Remote 。

关于git - 从本地分支推送到不同的远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28300580/

相关文章:

svn - 如何确定 svn :mergeinfo is corrupt and how would I fix it?

version-control - 在 Perforce 中更改分支

git - 如何在 git 中对齐列以改进格式?

git - 如果 git pull 请求仍待处理,我如何继续跨分支工作?

git - Git 中有哪些难以/不可能撤消的操作?

git - Composer : Multiple Packages in one Repo

git - 什么不应该包含在 flutter 应用程序的公共(public) repo 中

git - git pull、git fetch 和 git rebase 有什么区别?

git:如何创建我当前工作的一个分支,但保留在我原来的分支上

Git - 每个分支的不同远程