Git Commit Message Files#
Writing and maintaining documentation is always awful. Most of the times, it brings you out of the flow of thinking about and changing code. We know it’s good to write things down, but we don’t necessarily want to write this in another slightly different and sometimes more complicated system that only wastes more of our time and energy.
We do know it’s important. There are different kinds of documentation and especially when clients or users rely on documentation, there’s no other way we can have a succesful software project without doing these chores.
We do sometimes have a mutual understanding among developers in the same projectabout technical documentation or shall I say, the lack of technical documentation, as we just ask around and hack our way into some understandment of the project.
On the other hand, we also get into panic mode when we’re about to commit and suddenly have to think about writing the right commit message. “What does this commit do? What conventions are we using again? I think I’ll just write down this one-liner that tells us what this change is…”
Later on, we might wonder why we made certain decisions while we look at the code.
Start with a file that contains your commit message#
You can pass a file as a commit message as soon as you commit with
$ git commit --file <filepath>
$ git commit -F <filepath>
This made me change my development flow.
Nowadays, I start with a text file right away that contains the commit message and the convention we’re using, right after it’s clear what I’m going to do first. As I change the code and it feels necessary to write things down, I use this text file where I write down the thoughts behind certain changes. Sometimes I even write a todo list in there that changes gradually into the definitive description of the eventual commit.
Check logs#
The most basic way to check the logs and diffs is:
$ git log -p <filepath>
Now when you use commit files for a while, you can not only see the changes with that command, but hopefully also see why and how these changes have been made.