[英]Gitlab cannot merge reverted branch with another branch
i have a gitlab problem.我有一个 gitlab 问题。 Let's say i have branch A,B,C.
假设我有分支 A、B、C。 I once merge branch B to branch A and branch A to branch C.
我曾经将分支 B 合并到分支 A 并将分支 A 合并到分支 C。 Then i do some commits in branch C and i just realized that i merged the wrong branch.
然后我在分支 C 中做了一些提交,我才意识到我合并了错误的分支。 Then, i looked at the commit history of branch C and try to revert each commit from the the last one to the one that i commit where merged branch C with branch A. Now, when i tried to merge branch B with branch C, it says that "cannot merge this branch. the Source branch is X Commits behind target branch" or something like that.
然后,我查看了分支 C 的提交历史记录,并尝试将每个提交从最后一个提交恢复到我提交的提交合并分支 C 与分支 A。说“不能合并这个分支。源分支是目标分支后面的 X 提交”或类似的东西。
To note, that all the changes is not in local branch, but in the remote branch or the server branch.需要注意的是,所有更改都不是在本地分支中,而是在远程分支或服务器分支中。
How can i solve this problem?我怎么解决这个问题?
If you are alone working on branch C, I would reset --hard
it to a commit just before the merge of A (wrong branch) to C.如果您一个人在分支 C 上工作,我会将
reset --hard
为在将 A(错误分支)合并到 C 之前提交。
Then I would do the right merge, and remake the new commits I made before.然后我会做正确的合并,并重新制作我之前所做的新提交。
This is better done locally, after cloning the GitLab repository, consideirng the menu associated to a commit in GitLab Web UI only allows for revert, not reset.最好在本地完成,在克隆 GitLab 存储库后,考虑与GitLab Web 中的提交关联的菜单,UI仅允许还原,不重置。
Once the local fix is done, you will need a git push --force
in order to override remote C with your new local history.本地修复完成后,您将需要
git push --force
以使用新的本地历史记录覆盖远程 C。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.