Commits
Here are a little bit more details about commits.
Each commit has a unique identifier
This identifier is a HASH string. A HASH is a deterministic value calculated based on an input. If the input changes, the HASH will also change. It's a quick way to compare two inputs are the same. In Git, the hash is long enough (256-bit) so that we can consider it to be a unique identifier for given a commit.
Data integrity is protected
Each HASH actually takes two components:
the previous commit's hash and
the changes set in the current commit
Hence a certain HASH enforces the entire history to be exact and ineditable. Any change in one commit will alter the current HASH and all downstream commit HASHes. This is like if the Terminator kills John, all history is rewritten.
In addition, the parent HASH of a commit is also recorded. Hence if HASH is provided for one commit, the entire change history before it can be back traced.
Each commit has a message
The commit message is added using git commit -m <msg>
.
The message documents what changes are made for documentation purposes. This will be shown in the git log
.
Last updated