Let's talk about the best practices for committing code.
First of all your commits shouldn't be too big or too
small. We don't want to make a commit, every time we update a
file, that's just useless. Because we'll end up with
commits like update five, one update file to occupy three,
it's just useless. On the other hand, we don't want our commits
to be too big, we don't want to wait and implement a feature end
to end before committing it. We don't want to code for three
days and then make a commit, because the whole point of
committing is to record checkpoints as we go. So if you
screw up, we can always go back and recover our code. So try to
commit often, in the real world, you might commit five to 10
times a day or even more, depending on the kind of work
you're doing. But this is just a basic guideline. Don't take it
as a rule. Don't try to aim for five or 10 commits a day. So as
you're coding, as you reach a state you want to record then
make a commit. And also, each commit should represent a
logically separate chain set. So don't mix things up. For
example, if you're fixing a bug, and then you accidentally Find a
typo in your app, you shouldn't come in both this changes in one
commit, you should have two separate commits, one commit for
the typo, another one for the bug fix. Now, if you
accidentally stage both these changes, we can easily onstage
them. I'll show you how to do this later in the section. Next,
you should give yourself the habit of creating meaningful
commit messages. Because all of these messages are going to show
up in history. So if your messages are cryptic, they're
not going to be helpful to you or other team members. If you
follow my previous advice, if a commit represents a single unit
of work, it would be easier to come up with a message for your
commit. If you're doing too many things in one commit, you're not
going to come up with a good message. Okay. Now in terms of
the wording, most people prefer to use the present tense in
their commit messages. So instead of fixed a bug, you
should say, fixed a bug. If you don't like this convention,
that's totally fine. But whatever commercial use, make
sure that you and other team members stick to it. So always
take this best practices in mind when committing code