थोड़ी देर के लिए मैं अपने व्यक्तिगत परियोजनाओं के लिए तोड़फोड़ का इस्तेमाल कर रहा हूं।
अधिक से अधिक मैं गीट और मर्क्यूरीयल के बारे में महान चीजों को सुनता हूं, और सामान्य में डीवीसीएस।
मैं पूरी DVCS चीज़ को एक चक्कर देना चाहता हूं, लेकिन मैं किसी भी विकल्प से परिचित नहीं हूं।
Mercurial और Git के बीच अंतर क्या हैं?
ध्यान दें कि मैं यह जानने का प्रयास नहीं कर रहा हूं कि कौन सा "सर्वश्रेष्ठ" है या यहां तक कि मुझे किसके साथ शुरू करना चाहिए। मैं मुख्य रूप से प्रमुख क्षेत्रों की तलाश में हूं जहां वे समान हैं और जहां वे अलग-अलग हैं, क्योंकि मुझे पता है कि वे कार्यान्वयन और दर्शन के संदर्भ में कैसे भिन्न हैं।
मुझे लगता है कि आप उन दो भावनाओं को महसूस कर सकते हैं जो उन दोनों वीडियो के समान हैं या उन दोनों वीडियो को ज़ाहिर करते हैं:
दोनों ही डिजाइन में बहुत समान हैं लेकिन कार्यान्वयन में बहुत अलग हैं।
मैं मर्क्यूरिअल का उपयोग करता हूं जहां तक मुझे गिट समझ में आती है, एक प्रमुख चीज जीआईटी अलग है यह कि वह फाइलों की फ़ाइलों को खुद के बजाय ट्रैक करता है लिनस का कहना है कि यदि आप फ़ंक्शन में एक फ़ाइल से दूसरे स्थान पर जाते हैं, तो गीता आपको इस कदम के उस एकल फ़ंक्शन के इतिहास को बताएगी।
वे यह भी कहते हैं कि git HTTP पर धीमा है, लेकिन इसका अपना नेटवर्क प्रोटोकॉल और सर्वर है
गीट मर्सूरियल की तुलना में एसवीएन मोटी ग्राहक के रूप में बेहतर काम करता है। आप एक एसवीएन सर्वर से खींच और पुश कर सकते हैं। यह कार्यक्षमता अभी भी विकास के अंतर्गत है
दोनों मर्क्यूरिअल और गीट में बहुत अच्छी वेब होस्टिंग समाधान उपलब्ध हैं (बिटबुकेट और गीटहब), लेकिन Google कोड केवल मर्कुरियल का समर्थन करता है वैसे, उनके पास तर्कसंगत और जीआईटी की एक बहुत विस्तृत तुलना है, जो यह तय करने के लिए किया था कि कौन एक का समर्थन करेगा ( http://code.google.com/p/support/wiki/DVCSnalysis )। इसमें बहुत अच्छी जानकारी है
मैंने कुछ समय पहले Mercurial के बंटिंग मॉडल के बारे में एक ब्लॉग प्रविष्टि लिखा था, और git के शाखा के मॉडल की तुलना में शामिल थे। शायद आपको इसे दिलचस्प मिलेगा: http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/
I use both quite regularly. The major functional difference is in the way Git and Mercurial name branches within repositories. With Mercurial, branch names are cloned and pulled along with their changesets. When you add changes to a new branch in Mercurial and push to another repository, the branch name is pushed at the same time. So, branch names are more-or-less global in Mercurial, and you have to use the Bookmark extension to have local-only lightweight names (if you want them; Mercurial, by default, uses anonymous lightweight codelines, which in its terminology are called "heads"). In Git, branch names and their injective mapping to remote branches are stored locally and you must manage them explicitly, which means knowing how to do that. This is pretty much where Git gets its reputation for being harder to learn and use than Mercurial.
As others will note here, there are lots and lots of minor differences. The thing with the branches is the big differentiator.
Take a look at Git vs. Mercurial: Please Relax blog post by Patrick Thomson, where he writes:
Git is MacGyver , Mercurial is James Bond
Note that this blog post is from August 7, 2008, and both SCM improved much since.
Mercurial is almost fully written in python. Git's core is written in C (and should be faster, than Mercurial's) and tools written in sh, perl, tcl and uses standard GNU utils. Thus it needs to bring all these utils and interpreters with it to system that doesn't contain them (eg Windows).
Both support work with SVN, although AFAIK svn support is broken for git on Windows (may be I am just unlucky/lame, who knows). There're also extensions which allow to interoperate between git and Mercurial.
Mercurial has nice Visual Studio integration . Last time I checked, plugin for Git was working but extremely slow.
They basic command sets are very similar(init, clone, add, status, commit, push, pull etc.). So, basic workflow will be the same. Also, there's TortoiseSVN-like client for both.
Extensions for Mercurial can be written in python (no surprise!) and for git they can be written in any executable form (executable binary, shell script etc). Some extensions are crazy powerful, like
git bisect .
If you need good Windows support, you might prefer Mercurial. TortoiseHg (Windows explorer plugin) manages to offer a simple to use graphical interface to a rather complex tool. As state here, you will also have a Visual Studio plugin . However, last time I tried, the SVN interface didn't work that well on Windows.
If you don't mind the command line interface, I would recommend Git. Not for technical reason but for a strategical one. The adoption rate of git is much higher. Just see how many famous open source projects are switching from cvs/svn to Mercurial and how many are switching to Git. See how many code/project hosting providers you can find with git support compared to Mercurial hosting.
After reading all over that Mercurial is easier (which I still believe it is, after all the internet community is of the opinion), when I started working with Git and Mercurial I felt Git is relatively simpler for me to adapt to (I started off with Mercurial with TortoiseHg) when working from the command line, mainly because the git commands were named appropriately according to me and are fewer in number. Mercurial has different naming for each command that does a distinct job, while Git commands can be multipurpose according to situation (for eg,
checkout ). While Git was harder back then, now the difference is hardly substantial. YMMV.. With a good GUI client like TortoiseHg, true it was much easier to work with Mercurial and I did not have to remember the slightly confusing commands. I'm not going into detail how every command for the same action varied, but here are two comprehensive lists: 1 from Mercurial's own site and 2nd from wikivs .
╔═════════════════════════════╦════════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Git ║ Mercurial ║ ╠═════════════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════╣ ║ git pull ║ hg pull -u ║ ║ git fetch ║ hg pull ║ ║ git reset --hard ║ hg up -C ║ ║ git revert <commit> ║ hg backout <cset> ║ ║ git add <new_file> ║ hg add <new_file> (Only equivalent when <new_file> is not tracked.) ║ ║ git add <file> ║ Not necessary in Mercurial. ║ ║ git add -i ║ hg record ║ ║ git commit -a ║ hg commit ║ ║ git commit --amend ║ hg commit --amend ║ ║ git blame ║ hg blame or hg annotate ║ ║ git blame -C ║ (closest equivalent): hg grep --all ║ ║ git bisect ║ hg bisect ║ ║ git rebase --interactive ║ hg histedit <base cset> (Requires the HisteditExtension.) ║ ║ git stash ║ hg shelve (Requires the ShelveExtension or the AtticExtension.) ║ ║ git merge ║ hg merge ║ ║ git cherry-pick <commit> ║ hg graft <cset> ║ ║ git rebase <upstream> ║ hg rebase -d <cset> (Requires the RebaseExtension.) ║ ║ git format-patch <commits> ║ hg email -r <csets> (Requires the PatchbombExtension.) ║ ║ and git send-mail ║ ║ ║ git am <mbox> ║ hg mimport -m <mbox> (Requires the MboxExtension and the MqExtension. Imports patches to mq.) ║ ║ git checkout HEAD ║ hg update ║ ║ git log -n ║ hg log --limit n ║ ║ git push ║ hg push ║ ╚═════════════════════════════╩════════════════════════════════════════════════════════════════════════════════════════════════╝
Git saves a record of every version of committed files internally, while Hg saves just the changesets which can have a smaller footprint. Git makes it easier to change the history compared to Hg, but then again its a hate-it-or-love-it feature. I like Hg for former and Git for latter.
What I miss in Hg is the submodule feature of Git. Hg has subrepos but that's not exactly Git submodule.
Ecosystem around the two can also influence one's choice: Git has to be more popular (but that's trivial), Git has GitHub while Mercurial has BitBucket , Mercurial has TortoiseHg for which I haven't seen an equivalent as good for Git.
Each has its advantages and disadvantages, with either of them you're not going to lose.
Check out Scott Chacon's post from a while back.
I think git has a reputation for being "more complicated", though in my experience it's not more complicated than it needs to be. IMO, the git model is way easier to understand (tags contain commits (and pointers to zero or more parent commits) contain trees contain blobs and other trees… done).
It's not just my experience that git is not more confusing than mercurial. I'd recommend again reading this blog post from Scott Chacon on the matter.
One difference totally unrelated to the DVCSs themselves:
Git seems to be very popular with C developers. Git is the de-facto repository for the Linux Kernel and this may be the reason why it is so popular with C developers. This is especially true for those that have the luxury of only working in the Linux/Unix world.
Java developers seem to favor Mercurial over Git. There are possibly two reasons for that: One is that a number of very large Java projects are hosted on Mercurial, including the JDK itself. Another is that the structure and clean documentation of Mercurial appeals to people coming from the Java camp whereas such people find Git inconsistent wrt command naming and lacking in documentation. I'm not saying that is actually true, I'm saying people have got used to something from their usual habitat and then they tend to choose DVCS from that.
Python developers almost exclusively favor Mercurial, I would assume. There's actually no rational reason for that other than the fact that Mercurial is based on Python. (I use Mercurial too and I really don't understand why people make a fuss about the implementation language of the DVCS. I don't understand a word of Python and if it wasn't for the fact that it is listed somewhere that it is based on Python then I wouldn't have known).
I don't think you can say that one DVCS fits a language better than another, so you shouldn't choose from that. But in reality people choose (partly) based on which DVCS they get most exposed to as part of their community.
(nope, I don't have usage statistics to back up my claims above .. it is all based on my own subjectivity)
I've used Git for a little over a year at my present job, and prior to that, used Mercurial for a little over a year at my previous job. I'm going to provide an evaluation from a user's perspective.
First, both are distributed version control systems. Distributed version control systems require a change in mindset from traditional version control systems, but actually work much better in many ways once one understands them. For this reason, I consider both Git and Mercurial much superior to Subversion, Perforce, etc. The difference between distributed version control systems and traditional version control systems is much larger than the difference between Git and Mercurial.
However, there are also significant differences between Git and Mercurial that make each better suited to its own subset of use cases.
Mercurial is simpler to learn. I got to the point where I rarely had to refer to documentation or notes after a few weeks of using Mercurial; I still have to refer to my notes regularly with Git, even after using it for a year. Git is considerably more complicated.
This is partly because Mercurial is just plain cleaner. You rarely have to branch manually in Mercurial; Mercurial will create an anonymous branch automatically for you if and when you need it. Mercurial nomenclature is more intuitive; you don't have to worry about the difference between "fetch" and "pull" as you do with Git. Mercurial is a bit less buggy. There are file name case sensitivity issues that used to cause problems when pushing projects across platforms with both Git and Mercurial; this were fixed in Mercurial some time ago while they hadn't been fixed in Git last I checked. You can tell Mercurial about file renames; with Git, if it doesn't detect the rename automatically – a very hit or miss proposition in my experience – the rename can't be tracked at all.
The other reason for Git's additional complication, however, is that much of it is needed to support additional features and power. Yes, it's more complicated to handle branching in Git – but on the other hand, once you have the branches, it's not too difficult to do things with those branches that are virtually impossible in Mercurial. Rebasing branches is one of these things: you can move your branch so that its base, instead of being the state of the trunk when you branched, is the state of the trunk now; this greatly simplifies version history when there are many people working on the same code base, since each of the pushes to trunk can be made to appear sequential, rather than intertwined. Similarly, it's much easier to collapse multiple commits on your branch into a single commit, which can again help in keeping the version control history clean: ideally, all the work on a feature can appear as a single commit in trunk, replacing all the minor commits and subbranches that the developer may have made while developing the feature.
Ultimately I think the choice between Mercurial and Git should depend on how large your version control projects are, measured in terms of the number of people working on them simultaneously. If you have a group of a dozen or more working on a single monolithic web application, for example, Git's more powerful branch management tools will make it a much better fit for your project. On the other hand, if your team is developing a heterogeneous distributed system, with only one or two developers working on any one component at any one time, using a Mercurial repository for each of the component projects will allow development to proceed more smoothly with less repository management overhead.
Bottom line: if you have a big team developing a single huge application, use Git; if your individual applications are small, with any scale coming from the number rather than the size of such applications, use Mercurial.