509 points · by lclark · 11y ago · 177 comments
http://lkml.iu.edu/hypermail/linux/kernel/0504.2/0670.html
We will also be celebrating Mercurial's 10th anniversary next week during the 3.4 Pycon sprint:
Git is an entirely appropriate tool for managing as something as large and complex as the Linux kernel, but I'm doing much simpler stuff, and Mercurial is simpler and has a much shallower learning curve. I'd recommend it unequivocally to teams of modest size working on average applications.
The state of git documentation is much better today than it was five or six years ago, so maybe its complexity is less of a big deal, but so far I've not encountered any issues with Mercurial that make me think "If only I was using git this would be easy!"
What I found with git was I had to maintain a fairly complex mental model of the current state of affairs, and because I'm not very intelligent that took quite a bit of effort. With Mercurial the model is much simpler, so I can spend more of my very limited attention on writing code. It's quite possible that I simply never took the time to learn git properly, but with Mercurial I didn't have to.
I started using Mercurial because the basic interface and operations appeared more natural to me. Also, at least at the time, the Windows support was better in Mercurial.
After working with some repos using Git, I fell in love with the staging area, and the ability to selectively stage parts of files. I am sure Mercurial has something similar, but it was built into Git.
The only thing that bugs me is that the Windows port appears to be stuck at 1.9.5 (yes, I know it's open-source so I should go fix it instead of complaining).
What? What gave you that impression? That's a really old version. Here's the last 3.3 Windows build:
http://bitbucket.org/tortoisehg/files/downloads/tortoisehg-3...
This was from the downloads page:
http://mercurial.selenic.com/downloads
Edit: Oh, crap, I completely misread that. You were talking about the git Windows version. Oh well. Mercurial Windows versions are staying quite up-to-date, thanks to the tireless work of Steve Borho.
http://www.selenic.com/hg/help/revsets
I have tried to switch to git multiple times. Every time, I keep coming back to Mercurial. The most difficulty I have with git is the non nonsensical naming of concepts. For eg, A branch is a pointer to a commit. Because of this, I experience a big mental block when I try to reason about something. With Mercurial this is very much easier. And if you are using a DVCS to any capacity you ll have to do this often.
Another great thing about Mercurial is how easy to get help about stuff. You can head to the IRC chat room and can have a very good chance of catching one of the developers who, in my experience, were very helpful...
This is a frustrating thing about how people tend to talk negatively about git. I think what you mean is "not named in a way I'm used to," because there's nothing nonsensical about this naming at all, and it's actually an incredibly simple and lightweight way to reason about naming things in version control (imo, I suppose). And it permeates basically every level of how git organizes information in a pretty darn uniform way.
To me mercurial's two kinds of built-in branches and several plugins to do branch-like things is much more complex, but I still wouldn't call it nonsensical. That'd just be admitting that I stopped thinking about it when it was strange and unfamiliar to me.
Personally, I much prefer git, and I researched both before I used either. But I wouldn't fault someone for preferring mercurial, particularly if part of the reason was that they were very comfortable using it.
Revsets together with templates can be used to build custom commands:
http://jordi.inversethought.com/blog/customising-mercurial-l...
There are also filesets that work similarly for doing queries on files (hg help filesets).
FYI, "e.g." stands for "exempli gratia" which is Latin for "For the sake of example".
So "for eg" is actually "for for the sake of example".
I really do feel like Git is appropriate for small projects. The .git store is incredibly small (because it only stores changes) and quite simple when you get used to it. You will only only need to use a tiny subset of Git's functionality (or, heck, just the Github web-UI if you wish).
I think the hardest thing about Git for big and small teams is getting used to the mental model of Git (branching, merging, master, etc). Once you get it down you realise that Git is less complex, not more...
PS - This comment is mostly in reply to the implication that Git is a better tool for large and complex projects like the Linux Kernel.
PPS - Mercurial might be a better tool yet still for small projects, I don't know enough about Mercurial to have a qualified opinion either way.
1. Local branches
Git has them, mercurial doesn't really. Mercurial wants you to use a lightweight clone (copy-on-write with hard links) instead. Lots of mercurial extensions deal with this however.
The lack of rebase in stock hg is probably directly driven by the lack of local branches that don't get pushed upstream by default.
2. Committing code
Mercurial, without extensions, doesn't have the git shelf. With extensions there's a few competing options like MQ, Shelve or Evolve.
Both these points make hg easier to learn (branch == clone is very easy to wrap your head around, commit behaves basically like svn/cvs).
One correction: Git does not store changes at all. It stores all the versions of files as separate "blobs". What keeps .git small, is that Git compresses the object database to pack-files. "git gc" does this for you.
Pro Git has a great chapter about how Gits internals work: https://git-scm.herokuapp.com/book/en/v2/Git-Internals-Plumb...
This picture sums the model nicely: https://git-scm.herokuapp.com/book/en/v2/book/10-git-interna...
For me studying Git internals has been a good lesson in software design. Git's core is very simple, yet somehow that makes it a really versatile tool.
> The .git store is incredibly small (because it only
> stores changes)
git stores a complete copy of each revision, not changesets. (Well, it is my understanding that a .pack compressed archive of objects may store some of the objects as changesets, but that's not the general case)Going into a directory and easily creating a repo there, where I need it, is great.
Canonical did something similar with their Bazaar tool.
I think this really is the key to understanding git as well. When you understand the git data structures, git makes sense. Otherwise, it can be quite difficult to grasp (http://ftp.newartisans.com/pub/git.from.bottom.up.pdf was really useful for me).
"Bad programmers worry about the code. Good programmers worry about data structures and their relationships." [1]
I actually refered to this when discussing switching from Java to Python. One of the biggest problems for me was not easily being able to see the types of the arguments to a function in Python. [2]
[1] http://programmers.stackexchange.com/questions/163185/torval...
[2] http://henrikwarne.com/2014/06/22/switching-from-java-to-pyt...
That's because of Duck Typing [1]. I really like Python for how quick and easy it is to make small pieces of software, but I fully agree that Duck Typing can become more of a hindrance on larger projects.
You can use doc comments to signify types. You mention you use PyCharm in your article, and it supports doc comments in it's autocomplete and code analysis, I find most popular libraries are commented well enough that PyCharm can understand them.
I also always try (and encourage others) to use names that are declarative for both purpose and type. Of course, you can't always rely on third party libraries (or even colleagues) to be so nice, but I find a good name (almost) always removes all the confusion that normally comes from a lack of static typing.
For example, one of Codecademy's very first Python lessons includes some code like this:
meal = 44.50
tax = 0.0675
tip = 0.15
Which I think is unclear. Imagine these were function arguments. calc_total(meal, tax, tip) is vague. Is meal an object, or a numeric value? (I could possibly see it containing a list of all items in the meal with prices). Tax is almost always a percentage, but what about tip? Judging by the the above values, we can assume a 15% tip, but we don't know if the customer was stingy and tipped $0.15, and by just name alone, we can't tell at all. calc_total(meal_cost, tax_percent, tip_percent)
It's now immediately clear to me the type and range of values it accepts. The tip_percent is also an example of when a good name can provide info that even static typing could not, because in either case it is a floating point (please let's not get into a debate about Decimal or currency types :P ). This is a very basic example, but it applies at all levels. Don't call the parameter "users" if the function is not expecting an iterable of User objects. Maybe "usernames" would be better. Etc.But of course, this only helps if the code you're working with is named well. In something like Java, you have better protection and tools when working alongside lower quality code. I also completely agree with you on point #2 about No Static Types. Navigating through my editor is so much easier in a static language than it is in PyCharm with large projects. And the most annoying thing is that autocomplete breaks with ORMs, and most ORM usage is actually flagged as a warning or error. Ugh.
I also feel very confident in the automated refactoring in something such as an IntelliJ Java project, or ReSharper, but am apprehensive about using PyCharm to refactor anything with usages spanning more than one file. Same goes for Javascript (or any other dynamic language, I suppose. Those are just the two I use).
Enjoyed the posts by the way, adding your blog to my reading list.
http://tom.preston-werner.com/2009/05/19/the-git-parable.htm...
But we've never figured out how to make it work financially. If anyone has any ideas I'm all ears (though pointing at github and saying "do that" isn't an idea that I can execute).
BTW, BK used to be pretty darned close to open source, you got the source code under a funky license that said "don't take out the part that lets us make money". We stopped shipping the source when we learned that the very first thing that someone committed to the repo was taking out the part that let us make money.
Out of curiosity, and please feel free not to answer, is BK still a viable commercial product bringing in significant revenue? And what obstacle do you see with going the platform/service route like github? I assume that's something you've seriously considered, even without open sourcing BK.
I'll admit we've fallen off the radar (well, we were never really on the commercial radar, the only "marketing" we ever did was getting Linus to use it and that wasn't intended as marketing, it was intended to keep the kernel from diverging like the BSDs did. But it turned out to be a form of marketing that has kept us alive).
We're gonna try some actual marketing. Stay tuned. We'll probably screw it up :) But we hired a marketing company, I've gone back to writing papers, we'll give it a try. If you have ideas on how we can put ourselves back out there, we'd love to hear them.
As for viable, heck yeah. We work well on big repos (better than git), we've got what we call nested collections of repositories (did I mention I suck at marketing, yeah, I came up with what to call it) that are sort of like submodules except they work exactly like a single repo, sideways pulls work, anything that works with one repo works with N repos, that includes all the guis, command line, everything. We've got an answer for binaries that works for gaming companies. We've got a sane user interface (that's what Mercurial copied, in a somewhat sketchy way).
Git is sort of like the wild west, it never met an idea it didn't want to implement (at least partially). We're more enterprise ready (yeah, over used term) in that we work hard to make sure that BK has all the guard rails, seat belts, etc, so that you can deploy to people who could care less how any SCM works and they don't drive themselves over a cliff. Definitely less cool than git in that we take away some (bad) options, but safer.
We have seriously considered open sourcing a version of BK. We've been doing a lot of performance work and we essentially have two BK's, the almost SCCS compat ascii format slow version (slow but any version of BK will talk to it), and the fast one with a new binary file format (stuff like show the top commit comments are 35x faster in the linux kernel, that number goes up as you add more csets). We considered open sourcing the slow one but that effort has stalled. It could be revived, it just has to be worth it to us.
The github ship, in my opinion, has sailed. Maybe we could have open sourced BK back before git and done a github thing but it's all flashy UI stuff and we sort of suck at that. We're really good at systems stuff (you'll see when we start doing marketing, we scale, git doesn't) but flashy? Not so much. We do our UI in tcl/tk (I know, I know, but we have one UI person who makes it all work on windows/linux/macos and tcl/tk is a big part of that. At least we wrote a C like language that compiles to tcl byte codes so we're out of tcl. Thank God.)
> Sure. I'd do it in a heartbeat if I could figure out how to make it work.
just upload it to github. :)It's not as far fetched as you might think though, we've been building million cset trees and git is so darn slow that we made a "bk fast-export" that spits out the stuff that git wants. Because Git was over 20x slower just running the commits.
Git has a large industry of value-add / support companies now. But no one commercial company can own or control the core. And that's one key reason why it's so popular and has such a large ecosystem around it. So to be like git, bitkeeper would have had to really give up central ownership and control. Commercial companies never do that unless they're going out of business anyway, they just can't.
https://github.com/git/git/tree/e83c5163316f89bfbde7d9ab23ca...
Of course, he also didn't have as much to explain at that stage :)
* He aches for the very best tool that will suit all his major needs.
* He mentions getting the data structures right first, which is of prime importance. And no, it doesn't mean you start building TreeFactoryAdapter's.
* He codes at the lowest level, in C (please don't whine about assembly), to maintain complete control over memory usage.
I shudder to think what he would come up with if he ever decides to take Common Lisp on a test ride.To borrow an overused cliché, the code was just the tip of the iceberg. The hidden body of the MVP was the design he had been thinking about for a while. But we, as external observers, can't really see or appreciate what was going on in his head as he planned this out. It doesn't feel like "real" work, which makes the small remaining part that does seem all that much more impressive. This is actually a real source of tension between certain programmers and managers: it's hard for managers to tell actual thinking apart from day-dreaming, so programmers just look lazy in their eyes.
Torvalds wrote about this himself in the interview:
> So I'd like to stress that while it really came together in just about ten days or so (at which point I did my first kernel commit using git), it wasn't like it was some kind of mad dash of coding. The actual amount of that early code is actually fairly small, it all depended on getting the basic ideas right. And that I had been mulling over for a while before the whole project started. I'd seen the problems others had. I'd seen what I wanted to avoid doing.
How do you achieve this level of productivity yourself?
Personally, I think the main quality you want, as I alluded earlier, is comfort. Get yourself to the point where you trust your tools (and yourself) enough to execute your ideas without apprehension. You want to build yourself up to the point where your tools—everything from your programming language to your editor to your libraries—don't get in the way. They should almost feel like extensions of you. Think about it like riding a bicycle or skiing where you start thinking exclusively about where you're going without being distracted by how. Ideally, you want to think about the problem you're solving and the abstraction you're building rather than the mundane details of how you convey this to the computer.
That's partly because of how the kernel is developed, but part of it was that the GitHub interfaces were actively encouraging bad behavior. Commits done on GitHub had bad commit messages etc, because the web interfaces at GitHub were actively encouraging bad behavior. They did fix some of that, so it probably works better, but it will never be appropriate for something like the Linux kernel.
I haven't ever looked at the kernel workflow, nor have I ever heard systematic criticism of Github's methodology. Does anyone else have input on what Linus may mean by his opinion?
> [...] nor have I ever heard systematic criticism of Github's methodology.
He's not only criticizing Github: > (a) make a real pull request, not the braindamaged crap that github
> does when you ask it to request a pull: real explanation, proper email
> addresses, proper shortlog, and proper diffstat.
>
> (b) since github identities are random, I expect the pull request to
> be a signed tag, so that I can verify the identity of the person in
> question.
Real explanation, proper shortlog, signed commit, etc. (Note that he didn't mention emojis.)All he seems to be asking for is that we take our time and do it properly. Makes all the sense in the world for a large, long-lived open source project like Linux. Imagine 20-year-old commit messages from FreeBSD would look like the ones we write today for, say, a npm module.
--- edit ---
Yeah ... nevermind. He explains it himself further down:
> Btw, Joseph, you're a quality example of why I detest the github
> interface. For some reason, github has attracted people who have zero
> taste, don't care about commit logs, and can't be bothered.
>
> The fact that I have higher standards then makes people like you make
> snarky comments, thinking that you are cool.
>
> You're a moron.
>
> LinusHere is Linus himself commenting on that exchange: https://lkml.org/lkml/2013/7/16/712
Another source for what was said: https://news.ycombinator.com/item?id=3962978
That's our Linus-kun.
Here is more of the exchange for context:
--- Umm. Notice how the "Joseph" I replied to had deleted all the comments he wrote?
That should tell you something. I smacked down a troll.
If I was polite to you all those years ago, and I was polite but firm in the two first responses, please give me credit for when I smack somebody down. There may be a reason for it. The fact that the person deleted his messages (or github deleted them for him - I have no idea what their comment policy is) and you cannot see that context any more online should not make you think that I suddenly went crazy.
Btw, since I get the github messages in email too, I have a copy. Joseph replied to those "polite but firm" messages where I explained exactly why I don't want to bother with github pull requests with this gem:
"I did not realizes that Linus' shit does not stink. Thanks for
clearing that up..."---
Github doesn't scale at all for large projects. The kernel is averaging over 8 changes an hour, 24 hours a day. That rate of change can never be handled by doing pull requests and web site review. It only can work with email and review and scriptable processes.
That's roughly one every other hour, so still not quite on the same level. And we do use tooling _in addition_ to GitHub, but reviews are done in PR and not over email.
(FWIW I personally wish more projects worked like the kernel's, but such is life)
By the way, we've been succesfully using Gerrit on smaller-scale projects as well (around 8 change-requests / day) and don't even want to think about going back to pull-requests.
Criticisms in the interview were essentially about low discipline that Github interface allows, and how they were not willing to adapt to the kernel needs, not about fundamental deficiencies of pull request based model.
So far nothing has been said about why pull requests via a website might handle less load than pull requests over email.
http://www.mcvoy.com/lm/bitmover/lm/talks/socal/
tl;dr: fan in/fan out scales great if you have BitKeeper or Git.
As such, you simply can't afford not to know it these days. In fact, I can't help thinking that not using Git should now be a major red flag for job candidates and prospective employers alike. Sure, not using your favourite tool may not be that big a deal, but not using what is to all intents and purposes the lingua franca of source code communication is a serious omission.
If I need to use it I will learn it then. I don't think most people care as such.
Torvalds: I think that many others had been frustrated by all the same issues that made me hate SCM's"
Actually, the adoption was caused by the network effect. It took off with a core group of Linux-involved developers promoting it religiously, then it went on like a fashion (we are git-wielders, we are cool), and ended up being the default choice for a lot of other projects that either depended on some degree on 3rd party git-managed modules, or wanted to benefit from the existing disciplined git-trained developers, or just... because (for all things being equal). Having this presumption that the adopters actually thought for themselves and Torvalds's brain-child got where it is now thanks to its own technical merits is a pleasant thought though.
I'm looking for something more like CVS/Perforce where you can check anything in, but then with a more Git feeling interface. What I'd really like to do is to look at Git feature by feature and build the closest thing possible that does not include cloning the entire history locally under normal use. I know that is the fundamental paradigm of Git, but it seems that something closer to a hybrid of Git and Perforce could be created. Not sure exactly what it would look like. It's just jarring to jump from Perforce/CVS to Git and I don't think that's completely due to the local repository model. It's how branching works, it's how merging works, etc.
I would put all binary files into git annex (as determined by `file`). This can be done by a commit hook automatically. With another hook that makes sure that `git annex pull` is run when the user checks out code, you'd have a solution that was close enough to automatic for most use cases.
(You'd have to help your users with weird situations from time to time, but that's true of git anyway.)
tl;dr: all the data sits in one or more binary server[s] and is fetched on demand when you ask for the file. We distinguish between text and binary so you can clone a tree and have all the text checked out and none of the binaries; you set up your build system to check those out as needed.
We rarely have a stable trunk. Branching takes too long so most people don't want to do it. Merging two branches is such a scary thing that people avoid branching in the first place. Or I've seen them copy code from one branch in one Eclipse window and paste into another separate project (on another branch) in another Eclipse window. They repeat this manually for the next 5 to 20 files. I don't think they've realized a merge can often be as simple as a button click or one SCM command. But hey, it works for them.
The one time on my team that someone was interested in exploring Git was when we couldn't find an up-to-date Maven SCM connector for SVN that played nicely with Eclipse. The solution? Use an older version of Eclipse.
- git status
- git add ...
- git reset ...
- git commit ...
- git log ...
- git push/pull ...
I guess that's "the basics" - what command should I learn next?
Other useful stuff: - git diff - git diff --cached - git log --graph --decorate --pretty=oneline --abbrev-commit --all - git cherry-pick - git stash
Disclaimer: wrote this a few years ago and it has way more users than I ever would have thought.
http://blog.kfish.org/2010/04/git-lola.html
Being able to see the graph structure made it far easier for me to get a grasp git's general structure and flow on a higher level.
More powerful history browsers to "lola": * gitk (graphical, developed in git's own repo) https://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to... * tig (console) http://jonas.nitro.dk/tig/manual.html
I respect this quality immensely.
I found the poll a bit misleading. There were separate categories for Git and GitHub, but AFAIK you were only supposed to choose one. I'd wager most of the GitHub users are also using Git, so the graph would look more like this[3].
[1] http://www.slideshare.net/IanSkerrett/eclipse-community-surv... [2] http://eclipse.dzone.com/articles/eclipse-community-survey-2... [3] http://i.imgur.com/CEkIHSQ.png