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 does a clean working directory mean in Git?
A clean working directory means there are no changes to tracked files. All files are committed, and Git shows no differences when you run git status.
Click to reveal answer
beginner
What is a dirty working directory in Git?
A dirty working directory means there are changes in files that are not yet committed. These can be modified, added, or deleted files that Git tracks as different from the last commit.
Click to reveal answer
beginner
Which command shows if your working directory is clean or dirty?
The command git status shows the current state of the working directory, listing any changes that make it dirty or confirming it is clean.
Click to reveal answer
intermediate
How can you make a dirty working directory clean?
You can make it clean by committing changes with git commit, discarding changes with git restore <file>, or staging changes with git add followed by commit.
Click to reveal answer
intermediate
Why is it important to have a clean working directory before switching branches?
Having a clean working directory prevents conflicts and lost changes when switching branches. Git requires this to safely move between different snapshots of your project.
Click to reveal answer
What does git status show when your working directory is clean?
AUntracked files listed
BModified files listed
CNo changes to commit, working tree clean
DMerge conflicts present
✗ Incorrect
When the working directory is clean, git status shows 'No changes to commit, working tree clean'.
Which of these indicates a dirty working directory?
AGit repository is empty
BNo files listed by <code>git status</code>
CGit prompt shows branch name only
DFiles listed under 'Changes not staged for commit'
✗ Incorrect
Files listed under 'Changes not staged for commit' means the working directory has uncommitted changes, so it is dirty.
How do you stage changes to prepare for a clean working directory?
Agit add <file>
Bgit clone <repo>
Cgit branch <name>
Dgit merge <branch>
✗ Incorrect
git add <file> stages changes, which is the first step to making the working directory clean after committing.
What happens if you try to switch branches with a dirty working directory?
AGit may prevent switching to avoid losing changes
BGit switches branches without any warning
CGit automatically commits changes
DGit deletes untracked files
✗ Incorrect
Git usually prevents switching branches if there are uncommitted changes to avoid conflicts or data loss.
Which command discards changes in a dirty working directory?
Agit commit
Bgit restore <file>
Cgit push
Dgit merge
✗ Incorrect
git restore <file> discards changes in the working directory, reverting the file to the last committed state.
Explain what a clean and a dirty working directory mean in Git and how you can check their status.
Think about what Git shows when you run 'git status'.
You got /4 concepts.
Describe the steps you would take to move from a dirty working directory to a clean one.
Consider both saving changes and undoing changes.
You got /6 concepts.
Practice
(1/5)
1. What does it mean when your Git working directory is described as clean?
easy
A. There are conflicts from a merge.
B. There are untracked files present.
C. There are changes staged but not committed.
D. There are no changes to commit; all files are saved in Git.
Solution
Step 1: Understand the meaning of a clean working directory
A clean working directory means no changes are pending to be committed or staged.
Step 2: Compare with other states
Untracked files, staged changes, or conflicts mean the directory is dirty, not clean.
Final Answer:
There are no changes to commit; all files are saved in Git. -> Option D
Quick Check:
Clean working directory = no uncommitted changes [OK]
Hint: Clean means no changes to commit or stage [OK]
Common Mistakes:
Confusing staged changes with clean state
Thinking untracked files mean clean
Assuming conflicts mean clean
2. Which Git command correctly shows the current state of your working directory?
easy
A. git push origin main
B. git commit -m "status"
C. git status
D. git checkout
Solution
Step 1: Identify the command to check working directory state
The command git status shows staged, unstaged, and untracked changes.