50

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?

What are some of the differences between these source control system? Which one is the best for a small 2 people project?

Community
  • 1
  • 1
Yaso
  • 633
  • 1
  • 6
  • 10
  • 1
    See [For home projects, can Mercurial or Git (or other DVCS) provide more advantages over Subversion?](http://stackoverflow.com/questions/1218471/for-home-projects-can-mercurial-or-git-or-other-dvcs-provide-more-advantages-o) – Matthew Flaschen Jul 06 '10 at 01:57
  • See http://stackoverflow.com/questions/161541/svn-vs-git/2549128#2549128 – VonC Jul 06 '10 at 03:55
  • http://stackoverflow.com/questions/885213/in-short-what-are-the-advantages-of-git-and-mercurial-over-subversion http://stackoverflow.com/questions/871/why-is-git-better-than-subversion – joeynelson Jul 06 '10 at 01:58

3 Answers3

62

SVN is different from Git and Mercurial, in that it is a single repository that all users have to pull and commit to.

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 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.

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:

  • 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
forquare
  • 324
  • 2
  • 16
Conceited Code
  • 4,517
  • 3
  • 29
  • 32
  • 7
    If this hasn't already been covered in one of the linked duplicates (listed in the question), you should post an answer on one of them. –  Jul 06 '10 at 02:35
  • 1
    Great definition. I actually work with mercurial at one company, and work with SVN at another company. I am thinking about utilizing Git for my own personal projects. I will follow-up with more details once I have a better understanding of git. – Ryan Watts Oct 02 '13 at 17:31
  • If you have to choose between mercurial and git. Go with git. I'm not saying it's better. But it's the one commonly used today. There is a much larger ecosystem surrounding git (Github, Stahs, Gitlab, IDE support, etc.) than mercurial. Plus most developers will have git installed and know how to use it. – Gellweiler Dec 07 '17 at 23:32
  • 3
    All the commands you list with hg are exactly the same with git, so that does not explain why you find hg easier. – Jean Paul Jun 05 '20 at 22:26
18

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 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.

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.

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. :-)

jacobbaer
  • 1,011
  • 8
  • 13
  • 2
    You can treat the distributed version control systems as if they were centralized, if that suits a large team's workflow. –  Jul 06 '10 at 02:45
  • 1
    True. I think that's why for modern projects they seem to be replacing SVN outright. See: github. But I think authentication/auditing is harder to accomplish with a DVCS because the username is self-supplied and the only (easy) way to do it is to share an SSH account. If you trust everyone with that key, it's fine, but SVN will tell you with much more certainty who did what, and people can have commit access without also having the ability to overwrite the whole repository - if I have the privileges to make a Git or HG commit, I have the privileges to wipe the whole thing. – jacobbaer Jul 06 '10 at 02:51
  • 1
    Git now supports PGP signed commits which are impossible to forge, just refuse non-signed commits if you're concerned with auditing. And authentication, you're talking like if you'd use the same SSH key? That's just stupid and totally insecure. – remmy Nov 09 '12 at 18:30
  • 3
    Whilst this thread is quite old, I have still come across it so felt it was necessary to correct "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." - this is nonsense, you can get it up and running as simply as installing svnserve and if you want security then block the SVN port in the firewall and allow access through SSH only (svn+ssh://...). – JamieB Feb 08 '13 at 14:24
7

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.

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).

goffrie
  • 461
  • 2
  • 7
  • bitbucket could be used for mercurial. – Maozturk May 17 '18 at 22:08
  • 1
    @Maozturk, Bitbucket has removed mercurial support and hg repositories will be removed on June 1, 2020. See: https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket. IMO, if someone is to invest some time learning a tool anyway, for version control with improved ways of working, git is very much worth it -- with its tremendous community support. Even for the beginners, learning few basic commands like clone/pull/add/commit/push gets us far enough. – vulcan raven Sep 19 '19 at 08:55