为什么我在 git 中执行 hg pull 后需要更新 hg 我只做 git pull

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19270303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:10:44  来源:igfitidea点击:

Why do I need hg update after hg pull while in git I'm doing only git pull

gitmercurial

提问by Alexander Kulyakhtin

In gitto pull and use the latest changes to my local repository I'm using git pull.

git我使用的本地存储库中提取和使用最新更改git pull

In hg, I also use hg pullbut it prints then

hg,我也使用,hg pull但它打印然后

run 'hg update' to get a working copy

运行“hg update”以获取工作副本

I do run hg updatebut I wonder why is this difference from git?

我确实跑了,hg update但我想知道为什么这与git?

回答by Mikel

The other answers don't actually answer the question, which is: why don't Git and Mercurial work the same? Is there a philosophical difference?

其他答案实际上并没有回答这个问题,即:为什么 Git 和 Mercurial 的工作方式不同?有哲学上的区别吗?

In Mercurial, pullis the opposite of push: it syncs the local repo with a remote repo without touching the working copy. So it's more consistent.

在 Mercurial 中,pull则相反push:它在不接触工作副本的情况下将本地存储库与远程存储库同步。所以它更一致。

In Git, pullis a fetchplus a merge, or a pullplus an updatein Mercurial terms. Usually this is what you want. So it's more efficient.

在 Git 中,pull是 a fetchplus a merge,或者是Mercurial 术语中的pullplus an update。通常这就是你想要的。所以效率更高。

The Distributed Version Control University talkhas a slide at the 4-minute markthat clearly demonstrates the way Mercurial works. Michael Ernst's Version control concepts and best practiceshas a similar diagram (included below):

分布式版本控制大学的谈话具有在幻灯片4分钟大关,清楚地表明水银的工作方式。Michael Ernst 的版本控制概念和最佳实践有一个类似的图表(包括在下面):

Distributed version control

分布式版本控制

回答by sschuberth

Because git pullinternally performs git fetchand git merge, whereas hg pullonly does what git fetchdoes. Just do hg pull -uinstead. See also this command equivalence table.

因为在git pull内部执行git fetchand git merge,而hg pull只执行执行的git fetch操作。只是做hg pull -u。另请参阅此命令等效表

Git fetch and mercurial pull do the same thing. Mercurial fetch and git pull do the same thing.

Git fetch 和 mercurial pull 做同样的事情。Mercurial fetch 和 git pull 做同样的事情。

Of course Mercurial and Git use different data structures internally, so at some point there is a technical difference in the implementation details. If you really care deeply about it, just compare the documentation for hg pulland git fetch. The Git wording is more technical and verbose, but in the end it is the same.

当然 Mercurial 和 Git 内部使用不同的数据结构,所以在某些时候在实现细节上存在技术差异。如果你真的很关心它,只需比较hg pullgit fetch的文档。Git 的措辞更加技术性和冗长,但最终还是一样的。

回答by Mark

To get equivalent git functionality enable the fetch Mercurial extension (bundled with Mercurial distributions), see fetch extension. It will execute a hg pull -u.

要获得等效的 git 功能,请启用 fetch Mercurial 扩展(与 Mercurial 发行版捆绑在一起),请参阅fetch extension。它将执行一个hg pull -u.