正常合并:
$ git merge feature01
$ git merge feature02一切都很好。
挤压合并:
$ git merge --squash feature01 # OK
$ git merge --squash feature02
Auto-merging src/aaa.js
CONFLICT (content): Merge conflict in src/XXX.js
....为什么会这样呢?如何使merge --squash工作(后续合并工作查找)?
发布于 2020-02-12 14:23:37
好吧..。我的直觉是,在您正在处理的分支之外,有feature01和feature02的共同历史……当你做普通的合并时,git可以看到这一点,它是合并计算的一部分……但是如果你和南瓜合并,那么这种共同的历史就会从gits的视线中消失,这可能会导致冲突……例如,在合并的第二个分支上,您修改了在第一个合并的分支上引入的更改...如果您尝试合并它,那么没有历史背景可以判断您是从第一个分支上的更改开始的……所以你会得到一个冲突。
发布于 2020-02-12 16:16:24
( @eftshift0 t0在他的评论中提到:)
如果在合并之前,两个分支的历史记录如下所示:
# featureA and featureB have some common history :
--*--*--x--a <- master
\
*--*--y--b <- featureA
\
*--*--*--c <- featureBgit merge featureA时,git使用现有的提交:--*--*--x--a-b‘<- master \/ *--*--y--b <- featureA \*-c <- featureB
它有足够的信息知道它应该使用y作为featureB的合并基础,另一方面,在运行git merge --squash featureB时使用
--*--*--x--a--b‘<- master \ *--*--y--b <- featureA \*-c <- featureB
它将创建一个与分支featureB不再相关的新提交,并在合并featureB.时尝试重新应用更改的x..y
您可以查看分支的历史记录:
从命令行使用客户端:git log --graph featureA featureB master
git gui,git-kraken,git-extensions,...https://stackoverflow.com/questions/60181849
复制相似问题