我正在学习 Git,并在 this site 上找到教程很有用。在该页面上,关于 merge ,它包括:
+---------- (D) ---------------+ / | \ (A) -- (B) -- (C) -------------- (E) -- (F) | | fix-headers master | HEAD
The merge commit is (F), having parents (D) and (E). Because (B) is the common ancestor between (D) and (E), the files in (F) should contain the changes between (B) and (D), namely the heading fixes, incorporated into the files from (E).
我不明白为什么你会担心共同的祖先B。为什么你不能直接 merge D和E产生F? D 将派生自 B 但可能包含您想要的差异。 B 和 D 之间可能有许多提交,进行了更改并删除了更改。
最佳答案
(我犹豫要问这是不是愚人节,我不想侮辱任何人...)
也许你不明白这是 git 为你做的 merge ?
问题:这是D和E,你能告诉我F应该是什么样子吗?
D E
using System; using System;
public void main() public void main()
{ {
Console.WriteLine("hello world"); Console.WriteLine("Hello world!");
} }
回答:不,你不能
但是,如果你知道 B 长这样:
B
using System;
public void main()
{
Console.WriteLine("hello world");
}
这变得很简单,git 可以自行处理。
不知道这是否回答了您的问题...
关于git - 为什么 merge 需要您考虑共同的祖先?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5513132/