Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  • Each commit has a unique identifier
  • Data integrity is protected
  • Each commit has a message
  1. Intermediate Concepts

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.

PreviousResolve conflictsNextThree Trees

Last updated 1 year ago