为什么我会与 `git rebase -p` 发生冲突 [英] Why do I get a conflict with `git rebase -p`

查看:58
本文介绍了为什么我会与 `git rebase -p` 发生冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 git rebase 如何处理合并.我认为使用 -p,它将能够重新调整已经解决的冲突合并.但它看起来不像.

I'm trying to understand how git rebase handles merges. I thought that with -p, it would be able to rebase conflicting merge that would have already been resolved. But it seams like it doesn't.

以下是说明问题的示例:

Here is an example to illustrate the issue:

git init
touch a && git add . && git commit -m 'first commit'
git branch b
git branch c
echo 'a' >> a && git add . && git commit -m a

git checkout b
echo 'b' >> a && git add . && git commit -m b

git checkout master
git merge b
echo ab > a
git add .
git commit

git checkout c
touch c && git add . && git commit -m c

git checkout master
git rebase -p c

在这里,我在应用合并提交时遇到了冲突.有人可以向我解释为什么吗?

Here I get a conflict applying the merge commit. Can someone explain to me why ?

推荐答案

不,-p 只是将合并提交保留在历史记录中,而不是将它们展平.文档明确表示这对手动合并没有帮助:

No, -p just keeps the merge commits in the history instead of flattening them. The docs explicitly say that this doesn't help with manual merging:

(来自手册页)

不会保留合并冲突解决方案或手动修改合并提交.

Merge conflict resolutions or manual amendments to merge commits are not preserved.

这篇关于为什么我会与 `git rebase -p` 发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆