无法解决重基冲突

问题描述 投票:16回答:3
foo:/opt/bar$ git status
# On branch develop
nothing to commit (working directory clean)

foo:/opt/bar$ git pull --rebase origin develop
From ssh://xxx/yyy
* branch develop -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: Subscription logging added.
Using index info to reconstruct a base tree...
<stdin>:120: trailing whitespace.
* @return integer
<stdin>:143: trailing whitespace.
* @return integer
<stdin>:166: trailing whitespace.
* @return integer
<stdin>:189: trailing whitespace.
* @return integer
<stdin>:212: trailing whitespace.
* @return integer
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging app/config/config.yml
CONFLICT (content): Merge conflict in app/config/config.yml
Failed to merge in the changes.
Patch failed at 0001 Subscription logging added.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

foo:/opt/bar$ git status
# Not currently on any branch.
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: app/config/config.yml
#
no changes added to commit (use "git add" and/or "git commit -a")

foo:/opt/bar$ git add -A

foo:/opt/bar$ git status
# Not currently on any branch.
nothing to commit (working directory clean)

foo:/opt/bar$ git rebase --continue
Applying: Subscription logging added.
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

foo:/opt/bar$ git add -A

foo:/opt/bar$ git status
# Not currently on any branch.
nothing to commit (working directory clean)

foo:/opt/bar$ git rebase --continue
Applying: Subscription logging added.
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

foo:/opt/bar$
git rebase git-rebase
3个回答
45
投票

你走在正确的道路上。你只需要使用跳过你有问题的提交。

git rebase --skip

你已经修正了冲突,但与之前的提交相比没有任何变化。在这种情况下,你不能只用 git rebase --continue因为你让 Git 创建一个空提交,这是不允许的。

如果您的提交与其他提交有冲突,您仍然应该使用 git rebase --continue.

--skip 选项也很有用,当你不想在新生成的历史记录中包含某些提交。


7
投票

git rebase --skip 确实是正确的解决方案,只是有一种情况会卡住,无法继续当前的rebase。

Git 2.0.2(2014年7月)已经修复了这个bug:参见 提交95104c7Brian M. CARLSON (bk2204):

rebase--merge* 修复 --skip 连发两起

如果 git rebase --merge 遇到了冲突。--skip 如果下一个提交也与之冲突,那么就无法工作。. 该 msgnum 文件永远不会用新的补丁号更新,所以实际上不会跳过任何一个补丁,从而导致一个不可避免的循环。

更新 msgnum 文件的值作为调用_merge的第一件事。 这也避免了在调用_merge中出现"Already applied"消息时,跳过提交。 对于调用call_merge的其他上下文没有明显的变化,因为msgnum文件的值在这些情况下保持不变。


0
投票

Git是说你解决的冲突在以后的提交中又被改变了&你在当前的情况下没有变化.现在git不允许你继续重垒,因为它不能创建一个空提交。

如果你做 git rebase --skip 现在,那么在下一次提交时,如果修改了该文件,就会再次出现同样的冲突&。

为了避免这种情况,你可以使用:git commit --allow-empty & 然后做一个 git rebase --skip.

这将防止不得不再次解决相同的冲突& 再次。

© www.soinside.com 2019 - 2024. All rights reserved.