0
0
Gitdevops~5 mins

git restore --staged to unstage - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the command git restore --staged <file> do?
It removes the specified file from the staging area, effectively 'unstaging' it, so changes won't be included in the next commit.
Click to reveal answer
beginner
How do you unstage all files that were added to the staging area?
Use git restore --staged . to unstage all files at once.
Click to reveal answer
intermediate
What is the difference between git restore --staged and git reset?
git restore --staged unstages files without changing the working directory, while git reset can unstage and also move the HEAD pointer.
Click to reveal answer
beginner
True or False: git restore --staged deletes your changes in the file.
False. It only removes the file from the staging area but keeps your changes in the working directory.
Click to reveal answer
beginner
Why might you want to use git restore --staged before committing?
To remove files accidentally added to the staging area, so you only commit the intended changes.
Click to reveal answer
What does git restore --staged file.txt do?
ACommits file.txt to the repository
BDeletes file.txt from the working directory
CRemoves file.txt from the staging area
DAdds file.txt to the staging area
Which command unstages all files at once?
Agit status
Bgit commit -a
Cgit add .
Dgit restore --staged .
Does git restore --staged delete your changes in the file?
AYes, it deletes changes
BNo, it only unstages the file
CYes, it resets the file to last commit
DNo, it commits the changes
What is a common reason to use git restore --staged?
ATo fix accidentally staged files before committing
BTo delete files from the project
CTo push changes to remote
DTo create a new branch
Which command is a newer alternative to unstage files instead of git reset HEAD <file>?
Agit restore --staged &lt;file&gt;
Bgit commit --amend
Cgit checkout &lt;file&gt;
Dgit push
Explain how git restore --staged helps manage your commits.
Think about what happens when you add files by mistake.
You got /4 concepts.
    Describe the difference between git restore --staged and git reset when unstaging files.
    Consider what each command affects: staging area, working directory, and commit history.
    You got /4 concepts.