问题描述
这个问题假设团队成员有一个有福的"中央存储库
This question assumes there's a "blessed" central repository that members of a team
- 克隆自
- 推动他们何时希望其他团队成员看到自己的贡献
- 从他们希望看到其他人的贡献时拉出来.
- 等
如果是这样,我会假设hg update
与svn update
类似(为什么会有两个命令执行完全相同的操作?).据我所知,hg update
更像是svn revert
.正确吗?
If so, I would assume hg update
is not analogous to svn update
(why would there be two commands that do exactly the same thing?). From what I can gather, hg update
more like svn revert
. Is that correct?
更新:
我对变基的理解主要基于此页面上的常见情况"部分:
https://www.mercurial-scm.org/wiki/RebaseProject
My understanding of rebase is largely based on the "A common case" section on this page:
https://www.mercurial-scm.org/wiki/RebaseProject
推荐答案
正如其他人指出的那样,但几乎没有.为了降低与svn update
的相似性(并提高对通用DVCS(尤其是Mercurial)的最佳做法的遵从性,[1]):
As others have indicated, almost but not quite. In order of decreasing similarity to svn update
(and increasing compliance with general DVCS, and specifically Mercurial, best practices[1]):
-
hg pull -u
(或hg pull
后跟hg update
),并且您的更改未提交,并且自上次拉取以来没有提交的更改.这与svn update
尽可能接近,但是DVCS的做法是非常糟糕的. DVCS的优点之一是,您可以在尝试将更改与其他合并之前提交更改,因此可以使用备份版本进行回滚并重试失败的合并,而这种做法可以将其放弃.不要这样做.
hg pull -u
(orhg pull
followed byhg update
) with your changes uncommitted and no committed changes since your last pull. This is as close tosvn update
as you can get, but is pretty bad DVCS practice. One of the niceties of DVCS is that you can commit your changes before trying to merge them with others, and thus have a backup version to rollback and retry a failed merge, and this practice gives that up. Don't do it.
hg pull --rebase
.这将拉动上游更改,将更改重新应用到这些更改之上,并允许您将更改作为线性历史记录推回去.最终结果看起来与Subversion修订历史非常相似,但是您获得了合并之前提交的DVCS好处.但是,我不知道这种操作方式的安全性在Mercurial和Git之间如何进行比较.在Git中,所做的更改的还原前版本仍将存在,直到您执行git gc
为止,但是Mercurial没有明确的gc
安全网.
hg pull --rebase
after committing your changes. This pulls the upstream changes, re-applies your changes on top of them, and lets you push your changes back as a linear history. The end result will look very similar to a Subversion revision history, but you get the DVCS benefit of committing before merging. I do not know how the safety of this mode of operation compares between Mercurial and Git, though; in Git, pre-rebase versions of your changes will still be there until you do a git gc
, but Mercurial doesn't have an explicit gc
safety net.
hg pull
,后跟hg merge
,所做的更改已提交到本地副本.尽管有下面的脚注1,这是进行svn update
功能类似物的传统Mercurial做法.这样会产生一个非线性的版本历史记录,但是所有更改都可以被跟踪和检查.
hg pull
followed by hg merge
with your changes already committed to your local copy. This is the traditional Mercurial practice for doing the functional analog of svn update
, notwithstanding footnote 1 below. This results in a nonlinear version history, but all changes are tracked and inspectable.
也就是说,以自己的方式考虑Mercurial(和其他DVCS)有很多智慧,而不是试图从Subversion/CVS风格的思考中转换过来.
That said, there is much wisdom in thinking of Mercurial (and other DVCSes) on their own terms, and not trying to translate from Subversion/CVS-style thinking.
- 如果您不是线性重写思想派的人.如果是,则
rebase
可能比update
更可取. Mercurial社区倾向于青睐update
.
- If you are not of the rewrite-history-to-keep-it-linear school of thought. If you are, then
rebase
is probably preferable toupdate
. The Mercurial community tends to favorupdate
.
这篇关于hg pull --rebase是否类似于svn update?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!