为什么我无法将当前分支的git设置为另一个存储库?

时间:2018-06-07 16:48:08

标签: git

git push --set-upstream staging master的输出:

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@bitbucket.org:exampleOrgAbcxyz/infrastracture-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.

我有一个staging遥控器。我想将当前仓库的staging分支推送到其staging分支上的master远程。

git remote -v
composer    git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (fetch)
composer    git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (push)
origin  git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (fetch)
origin  git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (push)
staging git@bitbucket.org:exampleOrgAbcxyz/infrastracture-staging.git (fetch)
staging git@bitbucket.org:exampleOrgAbcxyz/infrastracture-staging.git (push)

1 个答案:

答案 0 :(得分:1)

git push staging master会尝试将 master 分支从您的本地仓库推送到master回购中的staging分支。在这种情况下,它会失败,因为您的本地master位于远程的staging之后。

要将master推送到远程git push staging staging:master,您需要git checkout staging。或/htdocs,然后是原始命令。