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 is the purpose of git stash push -m "message" <file>?
It saves changes from only the specified file(s) into a new stash with a message, leaving other changes unstashed.
Click to reveal answer
beginner
How do you stash changes from only one file without affecting others?
Use git stash push <filename> to stash changes from that file only.
Click to reveal answer
beginner
What happens to unstaged changes in other files when you stash specific files?
They remain in your working directory and are not stashed or removed.
Click to reveal answer
intermediate
Can you stash changes from multiple specific files at once?
Yes, by listing multiple files after git stash push, like git stash push file1 file2.
Click to reveal answer
beginner
What command shows the list of all stashes including those with specific files?
Use git stash list to see all saved stashes with their messages.
Click to reveal answer
Which command stashes changes only from a specific file named app.js?
Agit stash push app.js
Bgit stash save app.js
Cgit stash all app.js
Dgit stash file app.js
✗ Incorrect
The correct syntax to stash specific files is git stash push <filename>.
What happens to other unstaged files when you stash a specific file?
AThey are also stashed automatically
BThey get committed
CThey get deleted
DThey remain unchanged in the working directory
✗ Incorrect
Only the specified files are stashed; other files remain as they are.
How can you add a message to a stash when stashing specific files?
Agit stash save "message" <files>
Bgit stash push -m "message" <files>
Cgit stash message "message" <files>
Dgit stash add-message "message" <files>
✗ Incorrect
Use git stash push -m "message" <files> to add a message.
Which command lists all stashes including those with specific files?
Agit stash all
Bgit stash show
Cgit stash list
Dgit stash status
✗ Incorrect
git stash list shows all saved stashes.
Can you stash changes from multiple files at once?
AYes, by listing files after git stash push
BNo, you must stash all changes
CYes, but only with git stash save
DNo, only one file at a time
✗ Incorrect
You can stash multiple files by listing them after git stash push.
Explain how to stash changes from only one or more specific files in git.
Think about how to tell git exactly which files to stash.
You got /3 concepts.
Describe what happens to unstaged changes in files not included when stashing specific files.
Consider what git does only with the files you specify.
You got /3 concepts.
Practice
(1/5)
1. What does the command git stash push -m "save changes" file.txt do?
easy
A. It saves changes only from file.txt to a new stash with a message.
B. It saves all changes in the working directory to a stash with a message.
C. It commits file.txt with the message "save changes".
D. It deletes file.txt and saves the rest to stash.
Solution
Step 1: Understand the git stash push command
This command saves changes in the working directory to a stash instead of committing.
Step 2: Recognize the effect of specifying a file
By adding file.txt, only changes in that file are saved to the stash, not all files.
Final Answer:
It saves changes only from file.txt to a new stash with a message. -> Option A
Quick Check:
Stash specific file = It saves changes only from file.txt to a new stash with a message. [OK]
Hint: Use git stash push with file names to stash specific files [OK]
Common Mistakes:
Thinking it stashes all files without specifying
Confusing stash with commit
Assuming it deletes files
2. Which of the following is the correct syntax to stash only -index.html and style.css files?
easy
A. git stash push -- -index.html style.css
B. git stash push -- files -index.html style.css
C. git stash push -index.html style.css
D. git stash push -f -index.html style.css
Solution
Step 1: Recall the syntax for stashing specific files
The correct syntax uses git stash push -- <files> to specify files.
Step 2: Identify the correct option
git stash push -- -index.html style.css uses -- before file names, which is required to separate options from file paths.
Final Answer:
git stash push -- -index.html style.css -> Option A
Quick Check:
Use -- before files to stash specific files [OK]
Hint: Always use -- before file names in stash command [OK]
Common Mistakes:
Omitting -- before file names
Using unsupported flags like -f
Adding extra words like 'files'
3. Given these changes: -file1.txt modified, file2.txt modified, file3.txt unchanged. What will be the output of git stash push -- -file1.txt followed by git stash list?
medium
A. Shows an error because multiple files are modified.
B. Shows a stash with -file1.txt and file2.txt changes saved.
C. Shows a stash with only -file1.txt changes saved.
D. Shows no stash because file2.txt is not included.
Solution
Step 1: Understand what git stash push -- -file1.txt does
This command saves only changes from -file1.txt to a new stash.
Step 2: Check the stash list output
After stashing, git stash list shows the new stash entry with only -file1.txt changes saved.
Final Answer:
Shows a stash with only -file1.txt changes saved. -> Option C
Quick Check:
Stash specific file = stash list shows that file only [OK]
Hint: Stash command saves only specified files, stash list shows saved entries [OK]
Common Mistakes:
Assuming all modified files are stashed
Expecting an error when multiple files are modified
Confusing stash list output with file contents
4. You run git stash push -file1.txt but get an error: error: unknown option '-file1.txt'. What is the likely cause?
medium
A. You used the wrong command; git stash save is required.
B. The file -file1.txt does not exist.
C. You need to commit changes before stashing.
D. You forgot to add -- before the file name.
Solution
Step 1: Analyze the error message
The error says unknown option '-file1.txt', meaning Git treats the file name as an option.
Step 2: Identify correct syntax for stashing specific files
You must use -- before file names to separate options from file paths.
Final Answer:
You forgot to add -- before the file name. -> Option D
Quick Check:
Missing -- causes unknown option error [OK]
Hint: Add -- before files to avoid option parsing errors [OK]
Common Mistakes:
Omitting -- before file names
Assuming file must be committed first
Using deprecated stash commands
5. You have modified -app.js, index.html, and style.css. You want to stash only -app.js and style.css, then later apply those changes back. Which sequence of commands correctly does this?
hard
A. git stash push -app.js style.css git stash apply