What is a git commit?
Think of git commits as layers. Each layer is created atop its predecessor in an upward direction, with the oldest commits sifting to the bottom, and the newest at the top. Each commit represents a set of changes on top of the previous commit.
When you make more changes to your files, you are creating perturbations of the top layer. When you commit those changes, you are turning perturbations into a new discrete layer.
Other things a commit is
A commit has more qualities you should be aware of.
A commit is its commit id
Every git commit has a unique commit id. One commit is the same commit as another if and only if they both have the same commit id.
A commit is immutable
Once a git commit is created, it can never be modified. If you change any of a commit's attributes, that will spawn a new commit with the new attributes. But the old commit still exists, too (see git reflog )!
A commit is unique
A git commit is defined by the following attributes. One commit is the same commit as another if and only if the following attributes are exactly the same for both commits:
- Commit message
- Date the commit was created
- The commit(s) that came immediately before it
- The file system changes that the commit makes to the previous commit
- Who authored the commit