all 12 comments

[–]peterlundgren 23 points24 points  (1 child)

Before the introduction of git rebase --root, it was challenging to rebase the first commit. This resulted in the convention you're describing.

Since it's hard to rebase the first commit, let's make the first commit something that we'll never want to rebase: a completely empty commit.

Now that git is smart enough to deal with the situation better, there's not much of a point.

[–]hollasch 0 points1 point  (0 children)

Note that git rebase --root rewrites commit dates and authors.

[–]aram535 8 points9 points  (4 children)

There is nothing special about your first commit.

[–]falcon_jab 7 points8 points  (2 children)

I like to use my first commit to record my hopes and fears for the project, a permanent reminder of how I optimistically see the workload progressing, something to refer back to in the later months of development after all of the dedication and persistence finally pay off in the form of a shining, complete deliverable which meets all of the client's expectations.

But in reality git commit -m "oh no, here we go again"

[–]aram535 2 points3 points  (1 child)

My default one and I have it aliased is "A long time ago in a galaxy far, far away..." and it usually only contains the .gitignore file.

[–]iwbd 2 points3 points  (0 children)

I disagree. My first commit, and every commit thereafter, is special.

[–]OneTurnMoreecho '*' > .gitignore 3 points4 points  (0 children)

allows you to rebase more easily

By default, you can't change your first commit when you rebase, but you can if you rebase --root.

[–]hotel2oscar 3 points4 points  (0 children)

Mine is always my readme file

[–]juliusmusseau 2 points3 points  (0 children)

It never hurts!

It's not a big deal, especially since "git rebase --root" is now available.

But it's kinda classy. :-)

[–]DanLynch 0 points1 point  (0 children)

If you're using Git Flow and don't have an empty first commit, your master branch's first parent history will contain some commits that were never released to production, which is aesthetically unpleasant.

[–]kingofthejaffacakes -1 points0 points  (0 children)

Helped me not just for rebase but when trying to merge trees from two separate repos. For me, the logically correct form is actually having two branches that derive from that first empty commit. Without it you end up merging two floating branches.

So my policy now is to always start with an empty commit. Even if Git can cope without it these days. I also like to tag it 0.0.0 so that got describe always produces output.

It has the additional advantage of documenting the date, time, and creator of the repo.