DEV Community

Discussion on: Learn Git good practices!

Collapse
 
stephenwhitmore profile image
Stephen Whitmore • Edited

For point #2 good commit messages I started writing why I made the change rather than what the change is at the recommendation of a coworker. I've found it naturally provides a more meaningful commit history and kinda tells a story.

"Updated model to include license number" becomes "License number is tied to registration".

You already know I added a property by looking at the code change so comments like the former are redundant.

Collapse
 
primozkerin profile image
Primož Kerin

I would have no idea what you did based on your "License number is tied to registration".
You can do something like: "Update model to include license number" and then write your "why" in the description part of commit message. Just my 5 cents :)

Collapse
 
stephenwhitmore profile image
Stephen Whitmore

You make a good point - that wasn't the best example. Maybe something like "Added license number to model because it's tied to registration" would be better. I've found that generally putting reasoning behind the change helps a lot for the code review process and for going through old commits. I see lots of commit messages that are like "Added x" or "Removed y". It drives me nuts because I have to investigate further if I'm looking back through old commits when investigating something for example. Messages that give the reasoning behind the change saves time for things like that because you can hone in on the thing you're actually looking for or if you're doing a review it gives a clearer picture if you're not as familiar with the issue as the one who worked on it.