双重修改后如何继续合并?
我正在使用 git rebase -i 来重写历史记录 - 在本例中,对早期提交的更改集进行小的更改。换句话说,
A---B---C master
--->
A---B'--C master
我知道 C 也在隐式改变,但你明白了。这是我到目前为止的进展:
git rebase -i HEAD~2
- 将
B
从keep
更改为edit
。 - 编辑文件。
git commit -a --amend
git rebase --continue
- “无法应用 [C]...”
我已经解决了 C< 中的冲突行/code>,但我不确定如何将其标记为已解决,以便变基可以继续。
git commit --amend
尝试修改 B
,而 git rebase --continue
抱怨工作树脏了。 (果然,git status
将文件显示为“均已修改”。)
我需要做什么才能使此变基回到正轨?
I'm using git rebase -i
to rewrite history — in this case, make a small alteration to an earlier commit's change set. In other words,
A---B---C master
--->
A---B'--C master
I know C
is implicitly changing, too, but you get the idea. Here's my progress so far:
git rebase -i HEAD~2
- Change
B
fromkeep
toedit
. - Edit the file.
git commit -a --amend
git rebase --continue
- "Could not apply [C]..."
I've resolved the conflicted lines in C
, but am unsure how to mark it as resolved so that the rebase can continue. git commit --amend
attempts to amend B
, while git rebase --continue
complains that the working tree is dirty. (And, sure enough, git status
shows the file as "both modified".)
What do I need to do to get this rebase back on track?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您遇到冲突时,您应该看到类似这样的消息:
而这正是您需要做的:
不要尝试使用
commit --amend
。HEAD
(当前提交)仍然引用之前的提交,因为冲突阻止了此提交,所以正如您所看到的,这只是修改了已经应用的提交。rebase --continue
将继续进行包含已解决冲突的新提交。When you run into the conflicts, you should see a message something like this:
And that's exactly what you need to do:
Don't try to use
commit --amend
.HEAD
(the current commit) still refers to the one just before, since the conflicts have prevented this commit from being made, so as you saw, that just amends the already-applied commit.rebase --continue
will proceed to make the new commit containing the resolved conflicts.您是否尝试过显式执行此操作,即:
git add B'
,然后使用--amend
提交,然后执行git rebase --continue
?Have you tried doing it explicitly, i.e.:
git add B'
, then committing it with--amend
, then doinggit rebase --continue
?