I've come to think that the Git index is a good thing

February 24, 2022

Over on Twitter I said something:

It's funny how "we don't have an equivalent of the git index" is now a DVCS anti-feature for me. I like what the index enables and it has a clear conceptual model, even if it can be sometimes annoying.

(I agree that it's a bad name.)

There are two sides of thinking that Git's index is a good thing. The first is the practical side, where I like what it enables me to do. On the level where all VCSes are user interfaces to mathematics, the operations and double checks that the Git index readily enables are both useful and reassuring. Being sure of what you're going to commit before you do it and having powerful selective commit capabilities are both useful, and they're even better together.

Of course you don't have to have Git's index in order to support these operations. Plenty of other VCSes support partial commits (even committing just parts of files and changes), checking what you're going to commit in advance, and so on. The other side of Git's index is that it provides a clear conceptual model for all of them. By creating a clear separation between 'what is in your working tree' and 'what has been prepared to be committed', Git makes it more straightforward to reason about how various things are going to behave. It also makes things more inspectable; Git's staging area is a real thing with a concrete existence and commands that manipulate and inspect it.

Git's index isn't perfect, apart from the name, and a fully elaborated system could be built with a different conceptual model (for example, you could have a model that commits are built up over time, amended and modified until you freeze them). But having a straightforward conceptual model that cleanly enables the useful user interface features is a valuable thing.


Comments on this page:

By mboeh at 2022-02-26 20:01:35:

I rely a lot on the git index, and in most cases I find that thinking of it as a "staged commit" as you describe makes sense. That model is also pretty useful in explaining how to use most of the relevant commands. The only place it gets a little clunky is with git reset, but I think most people can get by without an intricate understanding.

Written on 24 February 2022.
« Some early notes on Dovecot namespaces (in Dovecot 2.2.33, currently)
The varying sizes of images on the web today, and remembering that »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Feb 24 22:27:05 2022
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.