What is a commit from Git's perspective?
A commit is a Git object that contains:
- a reference to the tree (the project's file structure);
- a reference(s) to the parent commit (one or more);
- the author and committer;
- the date and time;
- the commit message;
- a cryptographic hash (SHA-1 / SHA-256).
What "snapshot" means
- each commit captures the full state of the project;
- unchanged files are reused by reference, not copied;
- commits form a directed acyclic graph (DAG).
Why a commit cannot be changed
- a commit's hash is computed from its content;
- any change -> a new hash -> a new commit;
- this guarantees the integrity of the history.
How Git uses commits
- a branch is a pointer to the latest commit;
HEADpoints to the current commit;- a merge is a commit with multiple parents.
Short version for an interview
A commit is an immutable Git object that contains a snapshot of the project and references to previous commits.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.