Even as a solo worker, descriptive and atomic commits are valuable. They make merging or reverting changes a lot easier.
Even as a solo worker, descriptive and atomic commits are valuable. They make merging or reverting changes a lot easier.
Just the other day I wanted to find an old ticket which I couldn’t find via search. But I knew what changed in the code so I went to pull up the commit and… no ticket ID. And git does not provide any way to see which branch a commit was originally made to (our branches all have ticket ids in them).
I finally found it by searching PRs but it was painful.
My IDE leaves my previous commit message in the box which is awesome for me. Once I’ve committed once I just have to delete everything after the ticket ID and add my new commit message.
However, those hyper-detailed commit messages that some people seem to like? High cost, very low payback. Better to put all that effort into other docs instead.
> However, those hyper-detailed commit messages that some people seem to like? High cost, very low payback. Better to put all that effort into other docs instead.
I guess I'm one of those people? I don't think the cost is very high. It's certainly no higher than putting them into another document. I don't get the emphasis on "very low payback" though. I've had to dig into projects where those detailed comments saved me weeks of effort. I love reading the rationale and any associated pitfalls with a nice code diff contextualizing the whole thing. And it's right there, easily accessible in my SCM log, where it integrates with the CLI and IDE. No 404s or issues because the startup that created the project died or was sold and the domain is no longer in use.
I do it even on small personal projects, as soon as it’s evident it will go to production, I set up an issue tracker and commit messages. As common as setting the linter files in TS by default, even when just drafting a POC.
The Merge commit also updates the ChangeLog with the `TICKET-XXX - TICKET SUMMARY`.
That makes it really easy to trace things, as you can:
- Look at the ChangeLog
- Do a `git log --first-parent`
- Look at a Jira Ticket and jump straight to the merge commit
We also have policies in that every commit to master must be a merge commit and associated with a Jira Ticket. Also, each branch is tied to one and only one Jira Ticket.