Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Git Mental Model: Snapshots Not Diffs
📖 Scenario: You are working on a simple project with a few text files. You want to understand how Git saves your work as snapshots instead of just differences.This helps you see the whole state of your project at each save point.
🎯 Goal: Learn how to create a Git repository, add files, commit snapshots, and view the saved snapshots to understand Git's snapshot model.
📋 What You'll Learn
Initialize a Git repository
Create a file with exact content
Add the file to Git staging area
Commit the snapshot with a message
View the commit log to see snapshots
💡 Why This Matters
🌍 Real World
Developers use Git snapshots to save and track their project states safely and clearly.
💼 Career
Understanding Git snapshots is essential for collaborating on code and managing changes in software projects.
Progress0 / 4 steps
1
Initialize Git repository and create a file
Run git init to create a new Git repository. Then create a file named notes.txt with the exact content Hello Git.
Git
Hint
Use git init to start. Use echo "Hello Git" > notes.txt to create the file with exact content.
2
Add the file to Git staging area
Use git add notes.txt to add the file notes.txt to the Git staging area.
Git
Hint
Use git add notes.txt to prepare the file for commit.
3
Commit the snapshot with a message
Use git commit -m "First snapshot" to save a snapshot of the current project state with the message First snapshot.
Git
Hint
Use git commit -m "First snapshot" to save your changes.
4
View the commit log to see snapshots
Run git log --oneline to display the list of commits (snapshots) with their messages.
Git
Hint
Use git log --oneline to see your commit messages and IDs.
Practice
(1/5)
1. What does Git save when you run git commit?
easy
A. A backup copy of your entire computer
B. Only the changes made since the last commit
C. A list of all commands you typed
D. A snapshot of all your files at that moment
Solution
Step 1: Understand what git commit does
It records the current state of your project files as a snapshot.
Step 2: Differentiate snapshot from changes
Unlike some systems, Git saves the whole snapshot, not just the changes.
Final Answer:
A snapshot of all your files at that moment -> Option D
Quick Check:
Git saves snapshots, not diffs [OK]
Hint: Remember: Git snapshots whole files, not just changes [OK]
Common Mistakes:
Thinking Git saves only changes (diffs)
Confusing commit with backup
Believing commit saves command history
2. Which of the following is the correct command to create a snapshot in Git?
easy
A. git snapshot
B. git save
C. git commit
D. git backup
Solution
Step 1: Recall Git commands for saving work
The command to save a snapshot is git commit.
Step 2: Verify other options
Commands like git snapshot, git save, and git backup do not exist in Git.