作为一名 Mercurial 用户,我对它的理解是,在 Git 中,所有头都必须有唯一的名称。因此,除非您给它一个新名称,否则它不会创建新的头部。所以在 Mercurial 中你可以这样做:
hg pull / git pull
hg commit / git commit
hg commit / git commit
----B----C1----C2
您最初提取的基本修订版在哪里B
,C1 和 C2 是您的更改。然后,您从服务器中提取更新。
hg pull
----B----C1----C2
\
----o----o----o
Git 不会这样做,因为它必须创建另一个头。因此,您必须在服务器之上重新调整/移植您的更改。
git pull --rebase
----B----o----o----o----C1----C2
另一种方法是,当您在 Git 中开始工作时,您可以为自己的头脑命名。Git 称之为分支,Hg 称之为书签。
hg pull / git pull
hg bookmark / git branch
hg commit / git commit
hg commit / git commit
----B----C1----C2
^ New-Feature
现在头部有了一个名字(在这个例子中是“New-Feature”)。现在 Git 会像 Hg 一样愉快地拉动。
hg pull / git pull
----B----C1----C2
\ ^ New-Feature
----o----o----o
然后,您也可以以相同的方式合并。