Git vs Mercurial vs SVN
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3183064/
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
Git vs Mercurial vs SVN
提问by Yaso
Possible Duplicates:
For home projects, can Mercurial or Git (or other DVCS) provide more advantages over Subversion?
What are the relative strengths and weaknesses of Git, Mercurial, and Bazaar?
可能的重复项:
对于家庭项目,Mercurial 或 Git(或其他 DVCS)能否提供比 Subversion 更多的优势?
Git、Mercurial 和 Bazaar 的相对优势和劣势是什么?
What are some of the differences between these source control system? Which one is the best for a small 2 people project?
这些源代码控制系统之间有哪些区别?哪个最适合小型 2 人项目?
回答by Conceited Code
SVN is different from Git and Mercurial, in that it is a single repository that all users have to pull and commit to.
SVN 与 Git 和 Mercurial 不同,因为它是一个所有用户都必须拉取和提交的单一存储库。
Git and Mercurial have a distributed model. This means that there is a repository on every computer and there is usually an "Official" repository that people will choose to commit their changes to and pull from.
Git 和 Mercurial 有一个分布式模型。这意味着每台计算机上都有一个存储库,并且通常有一个“官方”存储库,人们会选择向其提交更改并从中提取。
Git and Mercurial are extremely similar. I prefer Mercurial because I found it much easier to use. For a 2 person team I would recommend Mercurial, but that is just my opinion. If you are not familiar with version control then you are still gonna have to spend your time learning to use any of the options, but Mercurial seemed the easiest for me.
Git 和 Mercurial 非常相似。我更喜欢 Mercurial,因为我发现它更易于使用。对于 2 人团队,我会推荐 Mercurial,但这只是我的意见。如果您不熟悉版本控制,那么您仍然需要花时间学习使用任何选项,但 Mercurial 对我来说似乎是最简单的。
To start a Mercurial repository all you have to do is open a shell and cd to the directory you want to have version control in, and type hg init
. That creates the repository. To add everything in the folder to the repository, type hg add .
. Here are some other various commands:
要启动 Mercurial 存储库,您所要做的就是打开一个 shell 并 cd 到您想要进行版本控制的目录,然后输入hg init
. 这将创建存储库。要将文件夹中的所有内容添加到存储库,请键入hg add .
。下面是一些其他的各种命令:
- To commit the local changes:
hg commit -m "Descriptions of changes"
- To pull to the latest version from the server:
hg pull
- To push the local changes:
hg push
- 要提交本地更改:
hg commit -m "Descriptions of changes"
- 从服务器拉取到最新版本:
hg pull
- 要推送本地更改:
hg push
回答by jacobbaer
To start with, there's the language they're written in. My experiences with Git and Mercurial have been very similar, but I know that if I want to tweak Mercurial, I can do it, because it's written in Python. Git is at least somewhat in C, which I'm not as familiar with.
首先,它们是用什么语言编写的。我使用 Git 和 Mercurial 的经历非常相似,但我知道如果我想调整 Mercurial,我可以做到,因为它是用 Python 编写的。Git 至少有点用 C 语言,我不太熟悉。
Git and Mercurial are what's called distributed. Every copy is created equal, and they can push and pull (using that terminology) changes from each other on an ad-hoc basis. Subversion, on the other hand, consists of a single central repository, and each working copy is a slave to that central server, pushing and pulling (committing and updating, in this case) changes from it and it alone.
Git 和 Mercurial 就是所谓的分布式。每个副本都是平等的,它们可以在临时基础上相互推送和拉取(使用该术语)更改。另一方面,Subversion 由一个单一的中央存储库组成,每个工作副本都是该中央服务器的从属,推拉(在这种情况下,提交和更新)来自它和它本身的更改。
Installing Git or Mercurial for a couple of people consists of getting SSH access to the same server and installing a couple of packages. Whereas for SVN, as far as I know you need to configure and run an actual server application under Apache, and then mess with an SSL cert and .htaccess, etc. to secure it.
为几个人安装 Git 或 Mercurial 包括获得对同一服务器的 SSH 访问权限并安装几个软件包。而对于 SVN,据我所知,您需要在 Apache 下配置和运行一个实际的服务器应用程序,然后使用 SSL 证书和 .htaccess 等来保护它。
For all my personal projects, I go with Mercurial or Git. If I were working with a large team, I'd probably go Subversion because you get centralized authentication and hosting. But for two people, I'd pick one of the distributed ones, because then you don't have to mess with centralized authentication and hosting. :-)
对于我所有的个人项目,我使用 Mercurial 或 Git。如果我与一个大型团队一起工作,我可能会选择 Subversion,因为您可以获得集中式身份验证和托管。但是对于两个人,我会选择分布式的一个,因为这样您就不必搞乱集中式身份验证和托管。:-)
回答by goffrie
Git and Mercurial are quite similar (but different enough to warrant caution). SVN on the other hand is quite different: the first two are distributed VCSs, so they do not require a central server, while SVN does. In general many projects are moving toward distributed systems.
Git 和 Mercurial 非常相似(但足够不同以保证谨慎)。另一方面,SVN 则完全不同:前两个是分布式 VCS,因此它们不需要中央服务器,而 SVN 则需要。一般来说,许多项目都在向分布式系统发展。
For your small project, you're probably better off with Git or Mercurial. Which one you choose is essentially a matter of taste, although I prefer Git myself (and am far more familiar with it). You need not set up a server at all: you can push/pull changes through SSH or even email patches to each other (this can be done directly from the VCS but is sort of a hassle). You can set up a central server at any time, and all the changes will be there. You can use e.g. GitHub or Gitorious to host your project (if you're going with Git, I don't know about Mercurial).
对于您的小项目,使用 Git 或 Mercurial 可能会更好。你选择哪一个本质上是一个品味问题,尽管我自己更喜欢 Git(并且更熟悉它)。您根本不需要设置服务器:您可以通过 SSH 推送/拉取更改,甚至可以通过电子邮件向彼此发送补丁(这可以直接从 VCS 完成,但有点麻烦)。您可以随时设置中央服务器,所有更改都将在那里。您可以使用例如 GitHub 或 Gitorious 来托管您的项目(如果您使用 Git,我不了解 Mercurial)。