This lesson will explain the importance of good commit messages, how to write them, when to commit and why having a history of good commits is so important!
This section contains a general overview of topics that you will learn in this lesson.
Yes! Let me give you a quick list of reasons why:
A good way to view a commit is like a “snapshot” of your code at the moment that commit was made. That version of your code up to that point will be saved for you to revert back to or look back at.
When writing code, it’s considered best practice to commit every time you have a meaningful change in the code. This will create a timeline of your progress and show that your finished code didn’t appear out of nowhere.
This means, make a commit if you get a piece of code you are working on to function like you want it to, fix a typo, or fix a bug. As you gain experience, you will develop a better feel for what should be committed!
There will come a time when you are working on a project and you FINALLY get something just right (this would be a good time to commit), and then maybe 30 seconds to a few days later it breaks. You have no idea what you changed, everything looks to be the same and you don’t remember editing that line, but alas, it isn’t working how you want it anymore. You’d be able to go back through your commit history and either revert your code back to the last commit you made when you first got that part working or go back and see what your code looked like at that point in time.
This section contains questions for you to check your understanding of this lesson on your own. If you’re having trouble answering a question, click it and review the material it links to.