0
0
Gitdevops~20 mins

git reset soft vs mixed vs hard - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Reset Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference between git reset --soft and git reset --mixed

After running git reset --soft HEAD~1, what happens to the changes from the last commit?

AThe changes remain staged in the index, ready to commit again.
BThe changes are unstaged and moved to the working directory.
CThe changes are discarded completely from the working directory and index.
DThe changes are saved in a new branch automatically.
Attempts:
2 left
💡 Hint

Think about what --soft means for the staging area (index).

🧠 Conceptual
intermediate
2:00remaining
Effect of git reset --hard on working directory

What is the effect of running git reset --hard HEAD~1 on your working directory?

AIt creates a new commit undoing the last commit.
BIt resets HEAD but keeps changes staged in the index.
CIt resets HEAD and unstages changes but keeps them in the working directory.
DIt resets HEAD and discards all changes in the working directory and index to match the previous commit.
Attempts:
2 left
💡 Hint

Consider what --hard means for both index and working directory.

💻 Command Output
advanced
2:30remaining
Output after git reset --mixed

Given a repository with one commit and some changes staged and unstaged, what is the state of the index and working directory after running git reset --mixed HEAD~1?

AHEAD moves back one commit, index is reset to that commit, unstaged changes remain in working directory.
BHEAD moves back one commit, changes remain staged in index, working directory unchanged.
CHEAD moves back one commit, all changes discarded from index and working directory.
DHEAD moves back one commit, changes are saved in stash automatically.
Attempts:
2 left
💡 Hint

Remember --mixed resets the index but not the working directory.

Troubleshoot
advanced
3:00remaining
Recovering a lost commit after git reset --hard

You accidentally ran git reset --hard HEAD~1 and lost the last commit. Which command can help you recover it?

A<code>git stash pop</code> to recover changes automatically.
B<code>git revert HEAD~1</code> to undo the reset.
C<code>git reflog</code> to find the previous HEAD and then <code>git reset</code> to restore.
D<code>git checkout -- .</code> to restore all files.
Attempts:
2 left
💡 Hint

Think about how Git tracks HEAD movements even after resets.

Best Practice
expert
3:00remaining
Choosing the right git reset mode for undoing commits safely

You want to undo the last commit but keep your changes safe and ready to edit before recommitting. Which git reset mode should you use?

A<code>git reset --hard HEAD~1</code> to discard changes and reset everything.
B<code>git reset --soft HEAD~1</code> to keep changes staged for editing.
C<code>git revert HEAD</code> to create a new commit undoing the last one.
D<code>git reset --mixed HEAD~1</code> to unstage changes but keep them in working directory.
Attempts:
2 left
💡 Hint

Consider which reset mode keeps changes staged for easy recommit.