git: empty commit message
When working with frameworks, like Ruby on Rails, there’s always the “initial commit” for all the files when commiting the first files for the application.
For me, I would like to have this “initial commit” to be the first commit into an empty repository, for example, the folder itself. The first commit is a blank slate and represents the start of the universe.
Let’s see what happens when trying to make an empty commit in a new repository:
Trying to create an empty commit of just the folder did not work… I want to have a commit that contains a message “start of the universe” and has not files or folders.
Documentation to the Rescue
Just looking around to see if there’s a solution, I dove deep into
git’s helper flags (
$ git commit -h), man pages (
$ man git
commit), but nothing helped.
A search pointed me to git-scm, one of the best git documentation.
Looking at git-scm’s documentation on git commit page reveals:
–allow-empty Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts.
git has an option to make an “empty” commit, exactly what I am looking for. Let’s see it working:
Cool - so now I can have empty commits in git, to indicate the “start of the universe”.
For those situations where an empty commit is necessary, use:
I like to use this when I start a project, I feel like I am “starting the universe”.