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
Recall & Review
beginner
What are the three main areas where files move in Git?
The three main areas are: Working Directory (where you edit files), Staging Area (where you prepare files to commit), and Repository (where committed files are stored).
Click to reveal answer
beginner
What command moves files from the Working Directory to the Staging Area?
The command is git add <filename>. It tells Git to prepare the file for the next commit.
Click to reveal answer
beginner
What command moves files from the Staging Area to the Repository?
The command is git commit -m "message". It saves the staged changes permanently in the repository.
Click to reveal answer
intermediate
What happens if you change a file after staging it but before committing?
The changes after staging are not included in the commit unless you stage the file again with git add <filename>.
Click to reveal answer
beginner
Explain the role of the Working Directory in Git.
The Working Directory is where you create and edit files. It reflects the current state of your project on your computer before staging or committing.
Click to reveal answer
Which Git area holds files you are currently editing?
ARepository
BStaging Area
CWorking Directory
DRemote Server
✗ Incorrect
The Working Directory is where you edit files before staging or committing.
What command stages a file for commit?
Agit add
Bgit push
Cgit commit
Dgit clone
✗ Incorrect
git add moves files from the Working Directory to the Staging Area.
After staging, how do you save changes permanently in Git?
Agit add
Bgit pull
Cgit status
Dgit commit
✗ Incorrect
git commit saves staged changes to the repository.
If you edit a file after staging it, what must you do to include the new changes in the commit?
ARun git add again
BNothing, it is automatic
CRun git commit twice
DRun git push
✗ Incorrect
You must stage the file again with git add to include new changes.
Which area in Git stores committed files?
AStaging Area
BRepository
CWorking Directory
DIndex
✗ Incorrect
The Repository stores committed files permanently.
Describe the journey of a file from being edited to being saved in Git.
Think about the commands and areas the file passes through.
You got /5 concepts.
Explain why staging is important in Git and how it helps control commits.
Consider how staging lets you choose what to include in a commit.
You got /4 concepts.
Practice
(1/5)
1. Which command moves files from the working directory to the staging area in Git?
easy
A. git add
B. git commit
C. git push
D. git clone
Solution
Step 1: Understand the role of git add
The git add command moves files from the working directory to the staging area, preparing them for commit.
Step 2: Differentiate from other commands
git commit saves staged files to the local repository, git push sends commits to a remote, and git clone copies a repository.
Final Answer:
git add -> Option A
Quick Check:
Staging area update = git add [OK]
Hint: Add files to staging with git add [OK]
Common Mistakes:
Confusing git add with git commit
Thinking git push moves files locally
Using git clone to stage files
2. Which of these commands correctly saves staged files to the local repository?
easy
A. git commit -m "Save changes"
B. git status
C. git add .
D. git init
Solution
Step 1: Identify the commit command
git commit -m "message" saves the staged files into the local repository with a message.
Step 2: Understand other commands
git add . stages files, git status shows status, and git init creates a new repo.
The file is created in the working directory, then moved to the staging area by git add.
Step 2: Commit the file
git commit saves the staged file to the local repository. The file remains in the working directory.
Final Answer:
In the local repository and working directory -> Option B
Quick Check:
Commit saves staged files, working files remain [OK]
Hint: Committed files stay in repo and working directory [OK]
Common Mistakes:
Thinking commit removes file from working directory
Believing staged files disappear after commit
Confusing staging area with repository
4. You ran git commit -m "Update" but Git says "nothing to commit". What is the likely cause?
medium
A. You committed files but did not push
B. You are in the wrong directory
C. You forgot to stage files with git add
D. You need to run git init again
Solution
Step 1: Understand the message meaning
"Nothing to commit" means no changes are staged for commit.
Step 2: Identify missing staging step
If you forgot git add, no files are staged, so commit has nothing to save.
Final Answer:
You forgot to stage files with git add -> Option C
Quick Check:
Stage files before commit = git add [OK]
Hint: Stage files first with git add before commit [OK]
Common Mistakes:
Thinking commit auto-stages files
Confusing push with commit
Assuming git init fixes this error
5. You edited app.js in your working directory. You want to save only this file to the local repository without including other changes. Which sequence of commands correctly moves app.js through Git's three areas?
hard
A. git add . then git commit -m "Save app.js"
B. git commit -m "Save app.js" then git add app.js
C. git push then git add app.js
D. git add app.js then git commit -m "Save app.js"
Solution
Step 1: Stage the specific file
Use git add app.js to move only app.js to the staging area.
Step 2: Commit the staged file
Run git commit -m "Save app.js" to save the staged changes to the local repository.
Final Answer:
git add app.js then git commit -m "Save app.js" -> Option D
Quick Check:
Stage then commit specific file = git add + git commit [OK]
Hint: Add specific file before commit to save only it [OK]