Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of commit messages?

I struggled asking that question but here it is. I am using source control since several years for multiple projects using different systems (svn, hg, git) and I learned how to improve my messages by following guidelines etc. But as far as I can remember I never ever had a look at them afterwards.

So ... how do you profit from your own commit messages? When I need to go back because I smashed something and need a fresh start, I usually just go back to the latest "node" (where I started or merged a branch). Do I write those messages just for people monitoring the project who are curious what is going on?

Regards

like image 495
ericteubert Avatar asked May 10 '10 21:05

ericteubert


People also ask

Do you need a commit message?

Strictly speaking, it's not necessary; it's just the default to enforce adding a commit message. You can use git commit --allow-empty-message to proceed without one.

Do commit messages matter?

Commit messages writing plays an important role in software development for it records, or documents the changes in natural languages during the progress of the project.

What is an example of a commit message?

For example, if you committed after making a simple update to the README file of a project, you might include a message that looks something like this: “Updates README for punctuation”. Now imagine a README file update with any of the following commit messages: “uPdatEd puNcTUatiOn”, “made fixes”, or “Chipotle rules”.


1 Answers

You write them as an aid to your future self, and others on the team. To give you some background of when I have found them useful:

I used to work on a project where commit messages were invaluable - on more than one occasion I used them to track down code that was years old. On that project our bug tracking system was also integrated with our VCS (ClearCase). So when you checked in a change, it would record the bug number in the commit comments. This was very helpful to allow you to trace back exactly what was changed and why.

So to sum it up, although commit messages may seem pointless if you are just starting out (especially if you are the only one working on the project), they become invaluable once you have a successful product that is supported in production by multiple developers.

Update

Another useful feature of commit messages is that they require you to review and summarize the changes you just made. Even if I remember what I have changed, I will often do a quick diff of a file before checking it in. I will briefly read it all over again to make sure there are no typo's, that I changed everything I meant to, etc. This is a simple way to review your code for those small little bugs that would otherwise find their way into your code. Anyway, after doing this I have a clear picture of what changed, so I use this to write a concise summary of the change when checking in the file. This is a simple habit that helps increase code quality with little effort on your part.

like image 142
Justin Ethier Avatar answered Sep 20 '22 15:09

Justin Ethier