Recall & Review
beginner
What does the command
git reset --hard do?It resets the current branch to a specific commit and discards all changes in the working directory and staging area, making the repository match exactly that commit.
Click to reveal answer
beginner
How can you find the commit hash before a hard reset?
Use
git reflog to see a list of recent HEAD positions, including before the hard reset.Click to reveal answer
intermediate
Which command restores your branch to the state before a hard reset?
Use
git reset --hard <commit-hash> where <commit-hash> is the commit before the reset, found via git reflog.Click to reveal answer
beginner
What is
git reflog used for?It records updates to the tip of branches and HEAD, allowing you to find lost commits or states after operations like hard reset.
Click to reveal answer
intermediate
Why is it important to act quickly after a hard reset if you want to recover?
Because Git's reflog entries expire after some time and garbage collection may remove unreachable commits, making recovery impossible later.
Click to reveal answer
What command helps you see previous HEAD positions after a hard reset?
✗ Incorrect
git reflog shows recent HEAD movements, including before resets.
Which command will discard all local changes and reset to a specific commit?
✗ Incorrect
git reset --hard resets the branch and discards changes.
If you want to undo a hard reset, what is the first step?
✗ Incorrect
Use git reflog to find the commit before the reset.
What happens if you run
git reset --hard HEAD~1?✗ Incorrect
This command moves HEAD back one commit and discards local changes.
Why might recovery from a hard reset fail after some time?
✗ Incorrect
Git cleans up unreachable commits after a while, making recovery impossible.
Explain how to recover your work after accidentally running a hard reset in Git.
Think about how Git tracks HEAD changes and how to move back.
You got /3 concepts.
Describe the role of git reflog in recovering from destructive Git commands.
It is like a safety log for your Git history.
You got /3 concepts.