简体   繁体   English

在gitlab中进行本地合并后无法推送

[英]Can't push after local merge in gitlab

I am following the gitlab instructions to perform a local merge of a release branch into our develop branch: 我正在按照gitlab的说明执行发行分支到我们的develop分支的本地合并:

Check out, review, and merge locally 在本地签出,查看和合并

Step 1. Fetch and check out the branch for this merge request 步骤1.提取并签出该合并请求的分支

 git fetch origin git checkout -b releaseX origin/releaseX 

Step 2. Review the changes locally 步骤2.在本地查看更改

Step 3. Merge the branch and fix any conflicts that come up 步骤3.合并分支并解决出现的任何冲突

 git fetch origin git checkout origin/develop git merge --no-ff releaseX 

Step 4. Push the result of the merge to GitLab 步骤4.将合并结果推送到GitLab

 git push origin develop 

I had previously pulled the release branch, so I started at step 3 on the develop branch. 我之前曾拉过release分支,所以我从开发分支的第3步开始。

git fetch origin - fetched a few changes in develop git fetch origin origin-在开发中获取了一些更改
git checkout origin/develop - created a detached head git checkout origin/develop创建一个独立的头
git merge --no-ff releaseX - merged with conflicts git merge --no-ff releaseX合并冲突

I manually resolved all the conflicts, then resumed with: 我手动解决了所有冲突,然后恢复为:

git commit - brought up the commit message editor; git commit出提交消息编辑器; saved and closed that 保存并关闭
git push origin develop

The attempt to push did nothing and replied with: 尝试推送没有任何反应,并回答:

Everything up-to-date

I'm not sure where to go from here. 我不确定从这里去哪里。 None of the answers I've found so far seem to apply to this. 到目前为止,我发现的所有答案似乎都不适用于此。 The closest I've found is this one , but I'm not sure if the scenarios discussed apply here. 我找到的最接近的是这个 ,但是我不确定所讨论的场景是否适用于此。

I should mention that I'm using git for Windows and git bash for this. 我应该提到,我在Windows上使用git,在git bash上使用。

The key part is: 关键部分是:

git checkout origin/develop - created a detached head git checkout origin/develop创建一个独立的头

If you are operating on a detached head, don't be surprise that pushing a local branch (like git push origin develop ) triggers... nothing: develop HEAD has not changed. 如果您使用的是独立的头,则推动本地分支(例如git push origin develop )会触发...不要感到惊讶:什么都没有:develop HEAD并没有改变。

Instead, update develop: 相反,更新开发:

git checkout develop
git pull

Then do your merge: git merge --no-ff releaseX : resolve conflicts, add, commit and push. 然后进行合并: git merge --no-ff releaseX :解决冲突,添加,提交和推送。

Is there any way to reattach the head to origin/develop ? 有什么办法可以使头脑重新适应origin/develop吗?

Yes: make sure your branch develop references your current (detached) head. 是:确保您的分支develop引用了您当前的(分离的)头部。
(Double-check that git status is still showing a detached head first) (仔细检查git status仍然仍然显示分离的头部)
See git branch -f : 参见git branch -f

git branch -f develop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM