8 ms·
Hg Init: a Mercurial tutorial by Joel Spolsky
- sumeeta 17y agoI like that Joel decides to say "OK, forget about Subversion or whatever you know about source control in general. I'm going to teach you about the DVCS way from the ground up." It's great that he treats this guide like an introduction to the concept of version control, but I think you really need experience with VCS before you can understand Hg Init. Is there an easy way to educate older and/or less technical IT professionals about source control? I haven't been able to do it myself, and I wish this was it.
- weaksauce 17y agoThis looks good from an overall why you should learn it point of view and also to help you with the lingo that you should know: http://betterexplained.com/articles/a-visual-guide-to-version-control/ http://betterexplained.com/articles/a-visual-guide-to-versio... For IT people you should have your /etc/* files under revision control to track any changes and easily roll back changes that break your system. I actually think there are some tools that are specifically for this purpose and not the general purpose SVN/git/hg variety but I cannot think of them off the top of my head.
- carey 17y agoYou're probably thinking of etckeeper: http://joey.kitenet.net/code/etckeeper/ http://joey.kitenet.net/code/etckeeper/
- jimbokun 17y agoWould any of this transfer to understanding how git works as well? Alternatively, is there a similar introduction to git? I'm in the camp of someone who has used CVS and Subversion a lot and have had "learn Git" or some other distributed VCS on my to do list for a while now.
- josephruscio 17y agoScott Chacon has a couple excellent resources: http://progit.org/book/ http://progit.org/book/ and http://whygitisbetterthanx.com/ http://whygitisbetterthanx.com/
- sreque 17y agohttp://whygitisbetterthanx.com/ http://whygitisbetterthanx.com/ doesn't represent mercurial 100 percent accurately. Cheap local branching: mercurial has had this since day one, and for a long time has had most of the capabilities mentioned in this section for a while. Unfortunately, it hasn't had good named branching support, so most mercurial users preferred to branch through cloning, but that was never necessary. Right now you can use bookmarks for temporary named branches but there's no built-in support for sharing them. You have to write your own extensions to copy bookmarks files around automatically or just do it manually. Mercurial really needs to deal with this, I think. It's the only feature I've seen in git that I wish mercurial had. Staging area: mercurial has mq, which is far more powerful than a staging area. In all honesty, I only use mq as a staging area and ignore it's other features most of the time, and using mq only as a staging area is just as easy as using git's staging area. Also, not having a staging area forced on the user by default makes mercurial much easier to pick up than git initially, and later on if a user wants the same functionality he or she can get it. github: Mercurial has bitbucket. Github is far more popular, but not necessarily technically superior as far as I know. That puts mercurial almost entirely on par with git in terms of this web site's criteria. edit: reading more carefully, http://whygitisbetterthanx.com/ http://whygitisbetterthanx.com/ doesn't actually claim mercurial doesn't have the features mentioned above. It does just claim that git does things better. They say their local branching is better(it is) and github's social atmosphere is better than competing products(it is). However, with mq and the record extension you can do the same things as with the staging area.
- Tichy 17y agoI think Google Code also does Mercurial now.
- 17y ago
- freetard 17y agoNote that the only reason Spolsky is doing this is because he bet on Mercurial a few years ago for his project http://www.fogcreek.com/Kiln/ http://www.fogcreek.com/Kiln/ which is Mercurial only. Unfortunately for him, git got more popular than hg so now he's promoting hg as much as possible.
- Quiark 17y agoOr maybe they don't want to risk a program that isn't 100% Windows compatible, because lots of their potential customers use Windows.
- weaksauce 17y agoI don't use windows much but msysgit is good. I was pleasantly surprised with it. The GUI is a bit fractured in terms of what it can do but the command line is competent. For a commercial product that needs to be integrated in the windows world like kiln I would have made the same decision that Joel did. (Though I prefer git overall)
- jefffoster 17y agoThere was a recent article by Martin Fowler (http://news.ycombinator.org/item?id=1131664 http://news.ycombinator.org/item?id=1131664) suggesting that the "view now is that msysgit is good enough to make comparison with Mercurial a non-issue for Windows." (edit change link to the YCombinator discussion)
- jrockway 17y agoAs a hardcore UNIX/git user, I've found the Windows git tools to be more than adequate.
- tghw 17y agoIf only Windows users were hardcore UNIX users...everything would be so much easier. No GUI code, no leaking GDI objects, no Java Swing, no WxWidgets, no cross-browser bugs (curl would be the only browser), no DPI scaling issues, no DLL hell, and no IE. Just text. Beautiful, green text. And it would all be BSD licensed. Oh, what a wonderful world that would be...
- deleted 17y ago[deleted]
- deleted 17y ago[deleted]
- solutionyogi 17y agoNow that's what I call organic SEO effort for their product Klin. I think patio11 will approve! :) EDIT: The above comment may seem negative but that's not the intention. As much as this site will help their SEO effort, I think the guide itself is awesome. I am a git user and when I was learning git, I went through similar 'examples' to understand git. I think this is the best way to learn git or hg! EDIT: I wanted to mimic the guide for git at gitinit.com and someone has already registered it!
- patio11 17y agoI have this funny feeling that Joel Spolsky probably does not need to read my blog for advice on effective software marketing. But yes, I approve. Do stuff like this. It works, it is inexpensive, it lasts forever, and your customers will love you for it. (Though if you're doing it for narrow SEO reasons, I might consider not breaking it into its own domain. Links pointing at it won't help the product rank if the product is on a domain different than the linkbait.)
- deleted 17y ago[deleted]
- alexgartrell 17y agoWhy is it better?
- deleted 17y ago[deleted]
- deleted 17y ago[deleted]
- matrix 17y agoIf this is advertising, I want more of it. As an SVN curmudgeon, the first part of this tutorial finally persuaded me that I really, really need to give distributed version control a fair trial. Joel pretty much nailed all my objections/complaints/whines about switching. But I also know the pain of merging all too well - a benefit that I hadn't really seen explained as persuasively before.
- hypermatt 17y agoIt reads really funny right? I enjoyed reading it even though I already used Git and the GFX were great. This is how all technical guides should be
- jamesbritt 17y ago" But I also know the pain of merging all too well - a benefit that I hadn't really seen explained as persuasively before." FWIW, try to give a few DVCS tools a shot before settling on one. I was a big hg fan, and really didn't care to switch when my coworkers ganged up on me and decided that git was a better tool, but I think they were right. The git command line leaves much t be desired; hg was far more intuitive. But I would occasionally have merging issues with hg that were just too annoying (lost or missing file changes, for example) that I haven't had with git. But that's anecdotal, and I'm sure (if you follow enough dvcs flame/troll threads :)) you'll hear other stories about other tools. The upshot is to try a few to see which works best for your particular needs.
- vog 17y agoI've had the opposite experience: There are scenarios where Git reverts some changes unexpectedly and almost silently, if you don't take care. In contrast, Mercurial's strict "every merge is an explicit commit" principle saved me from a lot of problems. Regarding the command line interface: Darcs has still the best one. Well, Darcs has some performance issues, but its interactive dialog-based command line interface is outstanding. It is years old, but neither Mecurial nor Git come even close to it. So if you have a small project or a fast computer, you should definitely have a look at Darcs in addition to Mercurial and Git.
- 17y ago
- mattchew 17y agoProof that Joel still has something to offer developers besides "if you were any good you'd be on StackOverflow right now". <g> As it happens I started moving to Mercurial yesterday, how is that for luck. I think the Hg site documentation is fine, but I have to say, Joel's is more fun right out the gate. May much Google juice flow his way.
- callmeed 17y agoI still can't get HG to build with MacPorts/SnowLeopard ... seems to be a problem with Python.
- mdg 17y agoTry one of these: http://mercurial.berkwood.com/ http://mercurial.berkwood.com/
- brodie 17y agoHave you tried the binary installer? http://mercurial.selenic.com/downloads/ http://mercurial.selenic.com/downloads/ If you're intent on building from source, make sure you're running "sudo python setup.py install; sudo make install-doc". Installing with the makefile directly will place packages in /usr/local, where Python doesn't normally live under OS X.
- ubernostrum 17y agoOr if you're serious about installing Python packages, you already have a .pydistutils.cfg file specifying where you want things to install. Learning a few options to put in that file is a lifesaver.
- inaequitas 17y agoI remember having to symlink /usr/local/lib/python2.6 to /Library/Python/2.6 so that site-packages are automatically included in $PYTHONPATH. You should also see what echo $PYTHONPATH says, and make sure site-packages is in there. For reference, mine is: /usr/local/lib/python2.6/site-packages/:/System/Library/Frameworks/Python.framework/Versions/Current/lib/:
- jasonkester 17y agoI always enjoy reading Joel's writing, regardless of whether I happen to agree with whatever he's saying. He can take on a subject as dry as comparing two version control systems, and make it enjoyable to read. Especially when he's working without an editor (his inc. stuff reads like it has been edited out of all recognizable shape.) Compare it to the normal dry, unreadable technical writing on similar subjects and it's just night and day.
- MikeMacMan 17y agoNice use of Balsamiq Markups in the diagrams, by the way.
- Estragon 17y agoThat was great. What does Kiln get you that Mercurial doesn't?
- jasonrr 17y agoKiln gets you a pretty cool (if I do say so myself) code review system, an all-new web interface for managing your code and repositories, tight integration with FogBugz, and support from Fog Creek. If you don't need those things, then by all means, use the open source version. There's a free trial of the hosted version that you can sign up for at http://www.kilnhg.com/ http://www.kilnhg.com/. Also, Kiln and FogBugz are both free for Students and Startups (2 users or less). Give it a shot and let us know what you think.
- kamens 17y agoKiln also takes care of all configuration/setup for you...and the On Demand version gets you regular off-site backups, secure data center hosting, all that good stuff.
- MartinCron 17y agoAs a kiln user, I'll back up Jason's statements here. Working with it day-to-day, it's not really any different from using the open source version of hg, but the web UI and code reviews are pretty damn cool.
- alanb 17y agoFor those of you comparing git and hg, I would suggest that they are actually quite similar. Check out this article "Mercurial for Git Users" here: http://mercurial.selenic.com/wiki/GitConcepts http://mercurial.selenic.com/wiki/GitConcepts It answered many of my questions on the nuances of Mercurial. The branch model, bare repositories, and command equivalence table were especially helpful for someone like myself who has used both systems but never fully understood the distinctions.
- Splines 17y agoNot having used Hg much at all (just a few hg commits and an hg clone), could it be used on top of a non-distributed source control system like SVN? E.g., take advantage of hg commit and related commands to try changes out on the local repository, and use svn to commit those changes to the central repository?
- iamelgringo 17y agoYou shouldn't have much problem with that. You'd just have to make svn ignore the .hg folder in your local repository, and you can use hg locally for whatever you want, and when you're at a point that you want to push your changes to your svn central repository, you can.
- noidi 17y agogit-svn does exactly what you describe: http://www.kernel.org/pub/software/scm/git/docs/git-svn.html http://www.kernel.org/pub/software/scm/git/docs/git-svn.html
- Luyt 17y agoDid someone also notice Kiln has a Dodo as logo? That bird went extinct in the late 17-th century (http://en.wikipedia.org/wiki/Dodo http://en.wikipedia.org/wiki/Dodo). I wonder what the meaning of this is. Maybe a pun on 'the way of the dodo', a place where your source code certainly won't go, if you use Mercurial.
- gecko 17y agoWe were looking for a good mascot for Kiln, but unfortunately, all of the animals that we consulted were already in exclusive contracts with other products except for Strigiphilus garylarsoni and the inverted flame-weasel, neither of which we felt represented our product well. Late one night in the Kiln alpha period, though, I was hacking around the Mercurial integration, messed up, and suddenly realized that issuing "hg up" held the repository at its current version, but moved time itself to match the requested revision. In other words, I had unintentionally made a time machine out of Mercurial. After riding a dinosaur for awhile, it hit me that I suddenly had a chance to get Kiln a legitimate mascot. I thought for awhile about where and when to go, then promptly "hg up"d to the mid 1600s. I went to the island of Mauritius, and approached the dodo bird. I explained that, through no fault of the poor bird, it was about to go extinct. But I had an option: I could "hg revert" the thing back into the present, restoring it from extinction, if only it'd be willing to sign an exclusive marketing contract for Kiln. We negotiated a little bit back and forth, but at the end of the day, as you can see, the dodo happily agreed. It now lives a life of luxury, and has even taken up recently to hanging around kiwi birds an awful lot. Unfortunately, the current version of Kiln can only restore deleted files, not deleted species, but we still think the dodo--a peaceful bird with no natural enemies, restored to the present--makes a nice mascot.
- Vitaly 17y agoI've just finished the introduction part and there is one thing he got wrong. the changesets vs revisions thing. Changesets and revisions are completely equivalent as far as merging is concerned (and almost anything else) because one is trivially computed from the other. and git which has even better merging support tracks file contents not diffs, which is another proof that this argument is irrelevant.
- inaequitas 17y agoIf you speak of Mercurial's changesets and revisions, they are clearly not trivially computed from one another, being that a revision is clone-specific, and a changeset is a hash computed on a single file by looking at all it's ancestors' states. REPO1 and REPO2 can both have 5 revisions and only one is common to both — a merge is possible, but the changesets considered will be very different. If you're comparing SVN's revisions with Hg's changesets, still no dice, for the same reason: changesets are unique for a file, given that file's history, and the hash trail allows for a clear way to figure out where changes happened, and merge from that point. A SVN revision just tells you how many commits have happened up to that point.
- cbetz 17y agoI find the choice of characters and the paragraph descriptions of them a little strange. I get the point that it helps the story to make up a whole life story for each member of the hypothetical development team. What I don't understand is why each team member is portrayed in such a negative light. Are your co-workers that bad?
- icco 17y agoI'm generally not a big fan of Spolsky's writing. He tends to read too much like a sales person, and too little like an engineer for me to enjoy his writing. This is a great read though, even if you already switched to git, because the two are so similar.
- ams6110 17y agoOK I just finished the first block (Subversion Reeducation) and one of the main points he makes is In Mercurial, every developer has their own repository, living on their desktop But if you read the subversion book, or any other good tutorials, you know that developers using svn can just as well make their own private branches So under branches/ I can have bob/ sue/ alice/ and they can have copies of trunk (or other branches) to their hearts content. So why is this a big "win" for Mercurial? (Will read the other sections later, no time now)
- anthonyb 17y agoIt's a win for DVCS in general, not just Hg. A couple of use cases off the top of my head: * I can take my repository on the train/bus/wherever and still commit. * If I'm working with someone who needs to use my 'buggy' code I can push just to their repository (or they can pull from mine). * I can have my own workflow and create as many branches, checkouts, etc. as I need. Of course, the example that he gives there is bizarre - effectively the Hg equivalent of hanging onto your code for 6 weeks and then merging all at once...
- nkassis 17y ago2 and 3 are easily done in SVN also. 2 is basically merging your changes in personal branch to the personal branch of another user. 3. Well your branch in SVN is your domain, do what you want. I think the main advantage is really for larger groups. Having 3000 branches in the linux repo would be unmanageable. Also, private branches are something SVN can't do to my knowledge. If I want to hack on a git repo without anyone knowing, it's easy. But there's many advantages to GIT/Mercurial over SVN/* aside from the "everyone has a repo". I love git but currently use SVN due to legacy and keyword expansion at work and it's not that bad.
- ecoffey 17y agoHere is how I (try) and explain it to my coworkers when they say "svn branches as well". You are right. Svn can branch. Can. But branching in svn is always a dangerous proposition. There are a lot of mechanics involved with branching it right initially, making sure that branch is properly tracking Trunk (you have to constantly merge from Trunk down into the branch to hedge the bets on eventually merging that branch back into Trunk). Properly merging a big branch into Trunk is also an undertaking, and more importantly, it requires the whole team to know its happening and "Be careful checking stuff in for I AM MERGING". Also branches in svn aren't private. Anyone can see them. They are private by convention sure. So compare all that workflow with a DVCS. The branching is free. It happens all the time and you never notice it. The merging is smarter, because it has to be, and the history is more complete, because it has to be to enable the merging. When you do consciously branch it's a quicker, more robust operation. Doing big scary feature branch merges isn't as scary since they're happening privately before you push back to the (culturally defined) central repo. Yes you still have to merge from "trunk" to branch in DVCS but, again, it's a baked in feature since thats how you pull changes from someone else (for example in git you fetch changes from the central repo into remotes/master and then merge them into your master. Same operation as merging master into feature branch, or branch into master). Yes you can walk to San Francisco from New York. But you can also Fly. That's the end of my rant. Obviously it's based on my experiences with these tools and not yours. Just trying to give some context and justification.
- Lorin 17y agoAlthough I wouldn't be using mercurial myself, I gave this a point simply because of the great site design and layout.
- iamelgringo 17y agoGreat writing Joel. Thanks.