0
0
Gitdevops~20 mins

Git mental model (snapshots not diffs) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Snapshot Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does Git store changes internally?

Git is often described as storing snapshots rather than diffs. What does this mean?

AGit stores file changes as patches that must be applied manually.
BGit saves only the differences between files for each commit.
CGit stores only the latest file versions and discards history.
DGit saves the entire state of all files at each commit as a snapshot.
Attempts:
2 left
💡 Hint

Think about how Git can quickly restore any commit without applying patches.

💻 Command Output
intermediate
2:00remaining
What does 'git cat-file -p HEAD' show?

Run git cat-file -p HEAD in a repository. What output do you expect?

AThe diff between the last two commits.
BThe full snapshot of the latest commit's tree and metadata.
CThe list of all branches in the repository.
DThe current status of uncommitted changes.
Attempts:
2 left
💡 Hint

HEAD points to the latest commit object.

🔀 Workflow
advanced
2:30remaining
How does Git optimize storage of snapshots?

Git stores snapshots for each commit. How does it avoid storing duplicate file data repeatedly?

AGit stores identical files only once using object hashing and references.
BGit compresses all files into a single archive per commit.
CGit stores full copies of all files for every commit without optimization.
DGit deletes unchanged files from previous commits to save space.
Attempts:
2 left
💡 Hint

Think about how Git uses SHA-1 or SHA-256 hashes for objects.

Troubleshoot
advanced
2:00remaining
Why does 'git diff' show no output after a commit?

You just committed changes, but running git diff shows no output. Why?

ABecause the commit was empty and did not change any files.
BBecause Git lost track of the commit history.
CBecause the working directory matches the latest commit snapshot exactly.
DBecause the repository is corrupted and cannot show diffs.
Attempts:
2 left
💡 Hint

Think about what git diff compares by default.

Best Practice
expert
3:00remaining
Why prefer snapshots over diffs in Git's design?

Git uses snapshots instead of diffs internally. What is a key advantage of this design?

AIt allows fast checkout and recovery by restoring complete file states directly.
BIt reduces repository size more than storing diffs would.
CIt makes merging changes impossible, simplifying history.
DIt requires less CPU power to compute diffs on demand.
Attempts:
2 left
💡 Hint

Think about how Git restores files when switching commits.