Do people actually read commit messages? I don't have much experience working on large projects with a larger team, but I keep repositories both for personal things and work so I can look at older versions. I have however never actually looked at my own commit messages, even though I try to keep them informative. I instead search through commits based on strings added/removed or file paths touched.
As such, multiline commit messages (whether added on the command line or via the editor) seem doubly pointless to me.I would be curious to hear how others view this.
nurettin|5 years ago
If it is like "f*ck python" or "lol java sux" that's a good indication that it was a syntax problem or a trivial mistake.
If it is like "a" or "aaa" or "x" it's just useless and you are on your own.
yjftsjthsd-h|5 years ago
If. The flip side is that when you don't have the issue tracker (I'm unclear as to whether they deleted it, or it just didn't come along when the product was acquired), it's maddening. "This [massive, opaque] change fixes #123" "...gee, thanks; that tells me loads."
Ask me how I know.
war1025|5 years ago
Obligatory plug for `git log -p`, which is a much better tool for finding out how changes happened to a file.
You can also use `git log -p --follow` with a single file to track the file across renames and moves.
Symbiote|5 years ago
I can look through the list of commits for recent changes that seem like they might have caused a new bug, but a list of numbers is no help at all there.
teddyh|5 years ago
https://xkcd.com/1296/
gspr|5 years ago
I find them super useful even for personal, my-eyes-only code! They really help answering "why the hell did I write this line of code like that when this alternative version would be much simpler?". It usually goes "oh, there's the commit that changed it from the obvious thing to the weird thing", and then if I've been a good me, the commit message describes the rationale.
Yes, code comments can serve some of the same purpose, but they typically document why code is the way it is, not change of said code.
Tuna-Fish|5 years ago
For the maintainability of a large project with a lot of contributors, the quality of the commit messages is more important than the quality of the code itself. The code and the comments in it only contains the how and what is happening, and even those can get really muddled up in projects where something gets changed over and over again by different people over a long time.
The commit messages provide the why. They grant you a window to the perspective of the person who did the change, explaining why they did something the way they did.
arximboldi|5 years ago
Do you know the tool "git blame"? (You can also use it with "git gui blame", from Github, or from many text editors). It tells you which commit last changed each line of code. Then you can click and see the surrounding history and context.
If the git history is "well written" this is an invaluable tool for understanding the code and how it came to be the way it is! Super useful when working on large code-bases where lots of different people collaborate.
seventh-chord|5 years ago
I guess there is some value in being able to have a quick description of the commits shown when looking at the blame output though.
wadkar|5 years ago
I have used it, but it never “clicked” me. I am always uncertain about what to do next as I browse git blame on GitHub
cstuder|5 years ago
I even like this in my personal projects: It shows me how good both my commit messages and granularity are.
g-b-r|5 years ago
So your commit messages are always made of less than 80 characters, how can you claim that they are informative??
Personally I very rarely manage to keep them in a single line, almost always there's something to dump from my mind that will help a lot when I or someone else will have to deal with that commit a few months from now.
You don't read your messages because they really are not informative!
seventh-chord|5 years ago
I tend to dump information like that in "// NB (my name, current date) tralala"-style comments. Do you have git integrated in your editor so you have git-blame-style commit messages next to your code? If that is the case, I guess putting the information in the commit messages makes sense.
Maybe it just comes down to how we choose to store auxiliary information.
Tade0|5 years ago
jayflux|5 years ago
See the recent discussion here: https://news.ycombinator.com/item?id=23739076
oftenwrong|5 years ago
battery423|5 years ago
I use them for - Tracking work on specific jira tickets - Giving myself a simple/quick overview on what was done - Tracking down bugs by trying to understand if that code is doing what it should do (bug vs. on purpose) - If i need to revert something, i revert a git commit. might just happend once a year but if required its fundamental
I'm also always slightly surprised about discussions from this topic: Its a nobrainer to just do it.
Its cumbersome if you have to explain to colleges, who are working with code for longer then a few month, why you should just write proper git commits.
It is like 'i'm allowed to write code which does a lot if things but pls exlpain to me again how i write a proper git commit message' :(
lioeters|5 years ago
Or this one for a Markdown list: git log --since="last version" --pretty=format:'- %s'
It helps me to:
- See what feature areas have been recently worked on
- Check if commits have been pushed to remotes
- Gather all commit messages since last version, and copy & paste (and edit) into changelog
Occasionally, I need to go back through the history and find a specific change - I typically just grep the commit messages for a word or phrase.
I also read commit messages of forked repos, to keep informed of what's happening upstream.
dfinninger|5 years ago
We keep as much of everything as possible in Git, including configuration. I can look back to every time we've adjusted the memory of a service, every time the number of instances has changed and have descriptions as to why that was done, associated tickets, etc.
Another great reason is integration with hosted Git tools. I know that Bitbucket and Github (and likely many others) will populate a pull request title/description with the commit message. Putting all of the necessary background in the commit message is a great way to supply the reviewer with information surrounding the commit, which decreases turn-around time for PRs. That history and reasoning is now ticketing-system agnostic and available in all of the popular editors that I've used (Vim, Emacs, VSCode, Intellij).
Symbiote|5 years ago
The most recent commits are a load of merges, but the slightly older ones have very long commit messages. The first one I clicked [1] has 11 changed lines of code, and a 32-line commit message.
[1] https://git.kernel.org/pub/scm/git/git.git/commit/?id=23c431...
bluesign|5 years ago
Then you are working on a subset of code, and can see of your change is effecting something else, or where else you need to make changes.
Or maybe someone fixed a bug there, then from commit message you can go to related bug, see their intentions more clearly.
sonthonax|5 years ago
A string of commit messages on a branch saying, “add x”, “typo”, say a lot less than a single commit along the lines of “TICKET-XXX new feature”.
yodsanklai|5 years ago
Consider a bug fix, you want to know what was the bug, and why the fix is actually a fix. This is complementary to comments which don't tell anything about the code evolution.
A good commit message can save a lot of work to your colleagues and even yourself in the future.
jgwil2|5 years ago
kalleboo|5 years ago
jfkebwjsbx|5 years ago
If you work in projects with a hundred other engineers or projects with maintenance, then there is no way you can get a sane code base without commit messages and reviews.
However, if you work alone and do not need maintenance, then yes, they are pointless since you will never need to read them.
kevin_thibedeau|5 years ago
Six months later: Why did I do this?
mhh__|5 years ago
Guillaume86|5 years ago
bregma|5 years ago
Found the tautology.