Challenge - 5 Problems
Git Revert Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of
git revert HEAD?You run
git revert HEAD in a repository where the last commit added a file named notes.txt. What will happen?Attempts:
2 left
💡 Hint
Think about how
git revert works compared to git reset.✗ Incorrect
git revert HEAD creates a new commit that undoes the changes made in the last commit. It does not delete history but safely reverses changes.
🧠 Conceptual
intermediate2:00remaining
Why is
git revert safer than git reset for undoing commits in shared repositories?Choose the best reason why
git revert is preferred over git reset when working with others.Attempts:
2 left
💡 Hint
Think about what happens to commit history and collaboration.
✗ Incorrect
git revert safely undoes changes by adding a new commit, so others' work is not disrupted. git reset rewrites history, which can cause problems if others have based work on those commits.
🔀 Workflow
advanced2:00remaining
Which command sequence correctly reverts a specific commit safely?
You want to undo the commit with hash
abc1234 without affecting other commits. Which command sequence is correct?Attempts:
2 left
💡 Hint
Focus on reverting a specific commit by its hash.
✗ Incorrect
git revert abc1234 creates a new commit that undoes changes from that commit only. Other options either reset history or target wrong commits.
❓ Troubleshoot
advanced2:00remaining
What error occurs if you try to revert a merge commit without special options?
You run
git revert on a merge commit without any extra flags. What error message will Git show?Attempts:
2 left
💡 Hint
Think about what Git needs to know when reverting merges.
✗ Incorrect
Reverting a merge commit requires specifying the parent with -m option. Without it, Git cannot decide which side to revert.
✅ Best Practice
expert3:00remaining
What is the recommended way to undo a commit that has already been pushed to a shared repository?
You accidentally pushed a commit with sensitive data. What is the safest way to undo it without disrupting others?
Attempts:
2 left
💡 Hint
Consider the impact on collaborators and history rewriting.
✗ Incorrect
Using git revert safely undoes changes by adding a new commit. Resetting or rebasing and force pushing rewrites history and can break others' work.