A commit means the official recording of a group of changes. After a commit, that state of the project stays in history forever and you can return to it at any time.

Like a video game#

In games you press "save" before a hard level so that if you lose you can continue from there. A commit is that save, with the difference that earlier versions are preserved too.

What each commit contains#

  • The file changes
  • A message explaining what changed
  • The author's name and the time
  • A unique identifier

A good message#

A commit message should say "what" and, when needed, "why". For example, "Fix tax calculation error for empty orders" is far more useful than "changes" or "fix". These messages are a big help later when you search for the cause of a bug.

Good habits#

  • Each commit should hold one logical change, not a mix of unrelated work.
  • Small, frequent commits are better than one giant commit.
  • Review your changes before committing so nothing extra or confidential is recorded.

After a commit#

A commit is recorded only on your computer. For others to see it, you must send it to the remote repo (push).

A common mistake#

Committing passwords or large unrelated files. If it happens, deleting them in the next commit is not enough, because they stay in history.