Skip to main content

Ben Cromwell

Tag: Git

Git history is Tralfamadorian

Or, why I dislike squash merges.

Tralfamadorians have the ability to experience reality in four dimensions; meaning, roughly, that they have total access to past, present, and future; they are able to perceive any point in time at will.

Kurt Vonnegut

The code usually tells you the what and sometimes the how. It doesn’t often delve into the why.

That’s where the git commit messages come in. Squash merges tend to at worst eradicate them and at best jumble them into one single large commit message comprised of every squashed message. That makes it a lot harder to get to the meaning of what you were trying to find out, that led you to open a line of code’s associated git log in the first place.

Git is not that hard (really)

I’ve seen some criticism of Git recently, on Twitter, with a ton of likes, suggesting a large amount of people have a difficult time using Git.

Git is not that hard.

It really isn’t.

I think the problem stems from two main approaches.

### Problem the first: Shying away from the command line

The command line reveals all but can be daunting for the beginner. I’d come from TortoiseSVN and then Kiln’s Mercurial equivalent before starting down the git-path. I wanted a visual too. Gitk was dire, but gitg is excellent. You can run gitg from the command line from a repo directory and it’ll launch straight away and give you the nice familiar graph so you can see what’s happening. Despite using the command line most of the time I still use gitg alongside it constantly. There’s no substitute for the clear visual. I have an alias for git log that paints a pretty OK to follow graph into the terminal but you can’t beat that full UI.

Ensuring better git commit messages with a global template

I read the advice here some time ago, and I’ve been following it by and large.

However, only recently I discovered how to enforce a line limit when git-commit starts up nano:

~/.gitconifg:

[core]
    editor = nano -r 72

The problem is that doesn’t help limit the summary to 50 characters, which is what you need for log, shortlog, Github and general readability.

I’ve now expanded this into a full replacement for git’s commit template. It’s automated with ansible as part of my local-setup.