我分叉了一个github仓库,并在我的github仓库上工作。 我已经提出拉动请求并且已经完成。
在那之后上游有更多的提交,所以现在我想要改变,我想这就是我必须要做的。 但我得到了这些合并冲突:
First, rewinding head to replay your work on top of it...
Applying: Issue 135 homepage refresh
Using index info to reconstruct a base tree...
<stdin>:17: trailing whitespace.
%h4
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging app/views/layouts/application.html.haml
CONFLICT (content): Merge conflict in app/views/layouts/application.html.haml
Auto-merging app/views/home/index.html.haml
CONFLICT (content): Merge conflict in app/views/home/index.html.haml
Auto-merging app/views/home/_group_projects.html.haml
CONFLICT (content): Merge conflict in app/views/home/_group_projects.html.haml
Failed to merge in the changes.
Patch failed at 0001 Issue 135 homepage refresh
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".
我不知道如何修复这些,请帮忙。
重新定位可能是一个真正的头痛。您必须解决合并冲突并继续重新定位。例如,您可以使用合并工具(根据您的设置而有所不同)
git mergetool
然后添加并提交您的更改并继续
git rebase --continue
祝好运
当您在rebase期间发生冲突时,您有三个选择:
git rebase --abort
来完全撤消rebase。 Git将返回你的分支状态,就像调用git rebase之前一样。git rebase --skip
来完全跳过提交。这意味着将不包括由有问题的提交引入的任何更改。您很少选择此选项。git rebase --continue
。我的mergetool是kdiff3,但还有更多可用于解决冲突的东西。您只需要在git的设置中设置合并工具,以便在调用git mergetool
时可以调用https://git-scm.com/docs/git-mergetool如果以上都不适合你,那就去散步再试一次:)
注意:使用Git 2.14.x / 2.15(2017年第3季度),如果发生冲突,git rebase
消息将更加清晰。
请参阅commit 5fdacc1撰写的William Duclot (williamdclt
)(2017年7月16日)。
(由Junio C Hamano -- gitster
--合并于commit 076eeec,2017年8月11日)
rebase
:为没有经验的用户提供更清晰的解决方案
之前:
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort"
后:
Resolve all conflicts manually,
mark them as resolved with git add/rm <conflicted_files>
then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".')
可以通过将错误消息解决给他们帮助的人来改进git UI:缺乏经验和随意的git用户。 为此,确保这部分用户可以理解这些消息中使用的术语,并指导他们解决问题是有帮助的。
特别是,在git rebase期间未能应用补丁是一个常见问题,对于没有经验的用户而言可能非常不稳定。 重要的是引导他们解决冲突(这是一个三步骤的过程,因此很复杂),并向他们保证,他们可以逃脱他们无法用“
--abort
”处理的情况。 这个提交通过详细说明解决过程和避免含糊不清的git linguo来回答这两点。
如果你有很多提交到rebase,并且其中一些人正在发生冲突,那真的很痛。但我可以建议一种鲜为人知的方法,如何“压制所有冲突”。
首先,checkout temp分支并开始标准合并
git checkout -b temp
git merge origin/master
你将不得不解决冲突,但只有一次而且只有真正的冲突。然后暂存所有文件并完成合并。
git commit -m "Merge branch 'origin/master' into 'temp'"
然后返回你的分支(让它成为alpha)并开始rebase,但自动解决任何冲突。
git checkout alpha
git rebase origin/master -X theirs
分支已经重新定位,但项目可能处于无效状态。没关系,我们有最后一步。我们只需要恢复项目状态,因此它将与分支'temp'完全相同。从技术上讲,我们只需要通过低级命令git commit-tree复制其树(文件夹状态)。加上合并到当前分支刚刚创建的提交。
git merge --ff $(git commit-tree temp^{tree} -m "Fix after rebase" -p HEAD)
并删除临时分支
git branch -D temp
就这样。我们通过隐藏合并做了一个rebase。
我也写了一个脚本,这样就可以用对话的方式完成,你可以找到它here。