Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试使用gitlab CI保持两个git repo同步时发生错误,更新被拒绝_Git_Gitlab_Gitlab Ci - Fatal编程技术网

尝试使用gitlab CI保持两个git repo同步时发生错误,更新被拒绝

尝试使用gitlab CI保持两个git repo同步时发生错误,更新被拒绝,git,gitlab,gitlab-ci,Git,Gitlab,Gitlab Ci,我使用gitlab CI使我的代码库在两个不同的gitlab部署中保持同步。我只希望推送到一个gitlab部署,然后让CI自动推送到第二个gitlab部署 为了做到这一点,我在我的.gitlab ci.yml中添加了登录名,但是,在推到第二个gitlab部署时,我得到了错误: $ git pull origin master From https://gitlab.firstdeployment.com/MYGROUP/myrepo * branch master

我使用gitlab CI使我的代码库在两个不同的gitlab部署中保持同步。我只希望推送到一个gitlab部署,然后让CI自动推送到第二个gitlab部署

为了做到这一点,我在我的
.gitlab ci.yml
中添加了登录名,但是,在推到第二个gitlab部署时,我得到了错误:

$ git pull origin master
From https://gitlab.firstdeployment.com/MYGROUP/myrepo
 * branch            master     -> FETCH_HEAD
Already up-to-date.
$ git pull seconddeployment master
From gitlab.seconddeployment.com:MYGROUP/myrepo.git
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> io/master
Already up-to-date.
$ git status
HEAD detached at 6e8093e
nothing to commit, working directory clean
$ git push io master
To gitlab.seconddeployment.com:MYGROUP/myrepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'gitlab.seconddeployment.com:MYGROUP/myrepo.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.

我知道我可以强制使用
push-f
,但是,我不明白为什么我在做正确的
pull

git状态时会从CI中得到这个错误,你确定
git pull
做了你想要的吗?尝试
git checkout master
,然后
git pull
@LasseV.Karlsen您建议我在
git pull origin master
git pull second deployment master
之后执行
git checkout master