我有两个存储库。一份用于制作,一份用于演出。 alt(暂存)有一些文件和外部联系人正在处理它。无法删除。想要将代码从本地(原始产品)推送到暂存(alt)。添加这两个 Remote ,它们看起来像这样:
$ git remote -v
alt https://github.com/uname/staging.git (fetch)
alt https://github.com/uname/staging.git (push)
origin https://bitbucket.com/uname/prod.git (fetch)
origin https://bitbucket.com/uname/prod.git (push)
尝试推送到暂存:
$ git push staging master
To https://github.com/uname/staging.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/uname/staging.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
最佳答案
请尝试git pull origin
,以便使用必要的代码更新您当前的分支。解决 merge 冲突后,您将能够继续推送。
关于git 推送到替代主服务器被拒绝,因为推送的分支提示位于其远程后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53754306/