concept commit in category git

This is an excerpt from Manning's book Git in Practice.
Figure 1.9 shows a fairly common use case for rewriting history with Git. If you were working on some window code all morning and wanted your coworkers to see it later (or wanted to include it in the project), there’s no need for everyone to see the mistakes you made along the way. In the figure the commits are squashed together: so instead of having three commits with the latter two fixing mistakes from the first commit, we’ve squashed them together to create a single commit for the window feature. You’d only rewrite history like this if you were working on a separate branch that didn’t have other work from other people relying on it yet, because it has changed some parent commits (so, without intervention, other people’s commits may point to commits that no longer exist). Don’t worry too much about squashing work for now; just remember this as a situation where you may want to rewrite history. Much later, in technique 42, you’ll learn how to rewrite history and the cases where it’s useful and safe to do so.
What we’re generally interested in when reading the history (and why we clean it up) is ensuring that the changes between commits are relevant (for example, don’t make changes only to revert them immediately in the next commit five minutes later), minimal, and readable. These changes are known as diffs.
Listing 12.1. Good commit message format
Commits: first line is a summary (<51 characters). Commit messages should be structured like emails. The first line (the commit subject) should be treated like the subject of an email. It should make a brief summary that is elaborated on in the rest of the commit message. It should have 50 characters or fewer and always be separated by a new line from the rest of the commit message body. Without this new line, various output formats that try to display only the first line of the commit may get confused. The commit's message body can be split into multiple paragraphs which should be wrapped at 72 characters or fewer. The wrapping is done to ensure the output of tools like `git log` remains readable even when it adds indentation for diffs. Otherwise the commit message has no other limits on length; it should be as long as it needs to be to fully explain the commit. While the subject might describe what the commit does, the body should expand on why the change was made. It should also use the present tense to match the tense used by commit messages generated by commands such as git merge. If you're using GitHub (and some other tools) then the contents of commit messages can contain Markdown. You may use Markdown to add some formatting that looks good in ASCII or rendered such as using **bold**, _italics_, ~~strikethrough~~, `monospace` or lists bulleted with a `*` or numbered with, for example `1.`. You shouldn't go overboard with this but it can add some useful, basic formatting.
You’ve seen previously in the book how to create commits from all the changes in an individual file. Because commits should be as small as possible (as discussed in technique 4), sometimes there may be multiple changes to a file that you want to split into multiple commits. Of course, you could manually undo and redo these changes to the files, but that would be tedious. Fortunately Git provides various tools you can use to add only certain changes in certain files to the index staging area or directly commit them.