Ignition

Stefan "hr" Berder // // code

Thinking about how to start this blog lead me to remember about something I read a long time ago about git. I can’t find that blog post anymore but I had enough recollection to search my way through google and stackoverflow.

It was about the initial commit in a fresh new git repository. I’ve seen in various places [1] that an empty initial commit is good practice. Here is how to do it:

$ git init
$ git commit --allow-empty -m "ignition"

This is all swell and good but I couldn’t find an explanation as to why it is a good thing. I like to know why I should do things so I searched a bit more. I think there are two good points:

  1. some commands break without an initial commit (git log for example). Creating an empty commit puts the repository in a fully working state without having to push any code.
  2. heavy rebasing with a branch using a different initial commit is problematic.

After tinkering with the idea, I realized that adding an empty commit is like starting your repository from 0 rather than 1. Any developer, except for a few, should see the appeal in this practice.

Footnotes

[1]This link is originally about the empty tree SHA1 in git, an interesting internal.