Live data from Hacker News

Git koans

stevelosh.com

51–60 of 143 posts

Re: Git koans

#51

A lot of these are just plain wrong though or have a good reason and it makes me sad because I know Steve Losh uses a lot of Mercurial which I think has a much worse UI. 1. Silence: you can't alias built-in commands — for good reason. You don't change the defaults of commands, that's just going to cause problems with scripts. Why is it ignored silently? For starters because new git versions can add a command that wou…

1. If a new version of git adds a command that shadows one of your aliases, you'd really prefer "git foo" to silently run the new command? That's better than telling you "hey this isn't going to do what you think any more"? Do you have `try: foo except: pass` in your Python code too? Come on. There's no reason git shouldn't at least warn you on stderr here. 2. `git checkout -- somefile.py` does not have anything to d…

Error, man page, short usage. And the arrangement doesn't make much sense.

Re: Git koans

#53

The 'Only the Gods' one seems weird to me; maybe I just don't understand Git well enough, but it seems like that one's just a case of failing to understand what a branch is . A particular commit isn't made 'on' a branch, so to speak; it's just a SHA hash that has a particular SHA as a parent. And then a branch is a pointer to a particular SHA. So there's no way to know which branch a commit originated 'on', merely wh…

Although in implementation, a commit is not done on a branch, for the user, that is precisely what happens. You checkout a branch and you do a commit while on that branch. Thus, to the novice, it might be perfectly normal to expect Git to tell him what branches the commit was made on , even though that makes no sense from Git's point of view. I've never had that use case (knowing what branch a commit was made on ), b…

Branches are just mutable pointers to commits. You're imposing a mental model onto Git that simply isn't present.

Git is revolutionary, in part, because instead of asking "what's the mental model we want to emulate and then never mind if that matches the implementation", they gave developers credit that they can understand a handful of simple concepts and made the actual design and data model as simple as possible. Programmers know what pointers, SHA-1 hashes, and DAGs are, so just use them.

Re: Git koans

#55
post #33

Earlier quoted context omitted.

> I learned hg before git and the experience of switching to git was shockingly bad. I'm comfortable in both now and the big thing I'd miss if I went back to hg would be git stash (and I'm sure there's a hg plugin for it). What about the index? Or the branching (bookmarks kinda work now I think), or the better remote management?

I personally hate the index. It gets in my way far more often than I actually make use of it.

How does it ever get in the way? Just add `-a` and you can essentially ignore that there is an index on commits.

Re: Git koans

#56

Earlier quoted context omitted.

> The command addremove is genius That's the default of what git does even without a command.

No it's not. [alias] addremove = !git add . && git add -u That will do it though, so it's not too hard to add.

Git does it on `git commit -a`.

Re: Git koans

#57
post #31

The best part of this article IMO is the scrolling header on the left hand. Nice touch.

Really annoying on an iPad while zooming in on the text.

Re: Git koans

#58

The 'Only the Gods' one seems weird to me; maybe I just don't understand Git well enough, but it seems like that one's just a case of failing to understand what a branch is . A particular commit isn't made 'on' a branch, so to speak; it's just a SHA hash that has a particular SHA as a parent. And then a branch is a pointer to a particular SHA. So there's no way to know which branch a commit originated 'on', merely wh…

What you described is how git thinks of branches.

Most developers think of branches as something they commit to. Therefore they are surprised when later they can't tell which branch they committed to.

This could trivially be fixed with porcelain that puts the name of the branch the commit was made to at the end of the commit message.

The issue of branches not really being branches is not unique to git; most VCs I've ever used have had significant differences between what you would think of as a branch and actual branches (SVN doesn't even have branches, except as a convention).

Re: Git koans

#59

Earlier quoted context omitted.

Although in implementation, a commit is not done on a branch, for the user, that is precisely what happens. You checkout a branch and you do a commit while on that branch. Thus, to the novice, it might be perfectly normal to expect Git to tell him what branches the commit was made on , even though that makes no sense from Git's point of view. I've never had that use case (knowing what branch a commit was made on ), b…

Branches are just mutable pointers to commits. You're imposing a mental model onto Git that simply isn't present. Git is revolutionary, in part, because instead of asking "what's the mental model we want to emulate and then never mind if that matches the implementation", they gave developers credit that they can understand a handful of simple concepts and made the actual design and data model as simple as possible. P…

Maybe Linux kernel devs deserve that credit, but it's becoming increasingly clear that developers as a whole don't deserve that credit.

Re: Git koans

#60

Earlier quoted context omitted.

Mercurial is essentially git with a clean interface and drastically fewer workflows. If it weren't for github's existence I'd recommend hg to anyone. That said hg is the better choice for big software shops IMO, because of the lower training cost and because they probably won't use github anyway.

> That said hg is the better choice for big software shops IMO, because of the lower training cost and because they probably won't use github anyway. Considering more people know git I would assume the training cost for hg is higher.

More people use git; I'm becoming increasingly convinced that few of them actually know git.
Post reply on HN