Git is still awful

Posted in: —

In case it’s not obvious from the title, this is mostly just a rant.

For the longest time, I was a Mercurial holdout and used it for every personal project where the choice didn’t affect other people.

After a long time, I finally switched when:

  1. git had won (GitHub etc.) and,

  2. Magit gave me a decent interface, better than the Mercurial CLI.

But it is still awful. We can forget.

I consult for a team of developers, and it involves people who are not software developers by trade who are learning to program and therefore also learning to use git. Trying to help them through this is the most embarrassing part of my job – the part that makes me feel like we, as software developers, are a bunch of amateurs.

The other day I coached a work colleague through a problem. He is a very intelligent guy and a talented mechanical engineer, who is now picking up coding. The part he struggles with most of all is not all the coding, but git, to the point that he was ready to “throw the computer out of the window”, in his words.

This is what he did:

  • Started a new branch for his work (good)

  • Did some work and committed (good)

  • Pushed to GitHub (good, we don’t like losing work)

  • Did some more work to fix up his previous, unfinished work, and did git commit --amend (good, we don’t like dozens of commit messages like “oops I forgot this bit”, and squashing at the end is more complicated).

  • Tried to push again, and got this message:

    error: failed to push some refs to 'github.com:…'

    hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. If you want to integrate the remote changes, use 'git pull' before pushing again.

This is of course completely wrong: the local branch is ahead, it’s the remote branch that is behind. And git pull is the wrong solution. What he actually wants is git push --force-with-lease (duh!).

He did everything right, and nothing out of the ordinary, and yet faced this nonsense.

Git ought to have enough information to do something sensible here. It knows that the user has “amended” a commit. But its internal model doesn’t have a place to store that info, so it just throws it away. It then treats the old and new version of the commit as just two commits with a common parent, makes a guess about the relationship between the remote and local branches, and comes up with a bogus error message.

Git is trying to be safe, but just causing confusion. Confusion can cause almost as much lost time and work as caution.

The problems git has are not just to do with the user interface, although that aspect is bad in many ways. The interface can be improved a lot, with things like Magit, and in fact my colleague was using a VSCode port of Magit called edamagit, on my recommendation, because it takes a fair amount of pain out of common tasks.

Git is still suffering from the fact that is a “stupid content tracker”, as it calls itself. It doesn’t track things at the level it actually needs to, and so provides only basic support for the common things that developers need to do with it.

I don’t know what a better solution is. Some of the things we try to do in software development are kind of hard (branchy development, keeping track of changes in logical commits etc.), and so I think it’s reasonable that it might take a considerable amount of effort to get the mental model needed to support this work. But there are a lot of things here which are not to do with that.

I’d like to look into jujutsu, but I’m very concerned that I might make the hardest part of software development even harder, especially as it won’t be mature right now. Even if I look at it for myself, I could end up distancing myself from the git pain that everyone else has in the team, and thereby make things worse.

So, there is no call to action here. I’m just reminding everyone that the current situation is not good.

This is my personal blog, and does not necessarily reflect the opinions of my clients/employer or my church.

Comments §

Comments should load when you scroll to here...