Friday, September 2, 2011

Git's Poor Command Line Habits

Tom Lord's Arch, or 'tla', was one of the first open source distributed version control systems. It was widely criticized as having overly long names and convoluted command line interface. Linus's Git has shorter names, but the command lines can be just as perverse.

Take, for instance, the command to set the repository back in time by one commit:

git reset --hard HEAD^

OK, what's up with that? It was not necessary at all to introduce a idiosyncratic tree walking syntax just for Git ?

[edit: not to mention, git reset is as dangerous a command as rm * for pretty much the same reason.]

In Git, the HEAD^ shows the parent of the HEAD commit. But wait, there's more!
Use HEAD^^ to see the parent of the parent of the HEAD commit, if it exists, or HEAD~3 (that's a tilde, '~', not a hyphen) to show the great-grandparent.

There's not a lot of consistency to the various command line interfaces in Git; most of the commands make use of a mix of positional arguments and labelled parameters and options, which can make the commands rather arbitrary and thus needlessly more difficult to remember. The choice of command names is also rather spurious.

Git has some good qualities, and lots of documentation. But lots of programmers keep complaining that they can't remember what that particular command was they were looking for, and it is evident that with Git it is difficult to infer for many of us to infer the proper semantics based on the syntax of the options. It's not us, its you, Git! You're hard to remember!

No comments: