0
0
Gitdevops~10 mins

Difference between reset and revert in Git - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to undo the last commit but keep changes staged.

Git
git [1] --soft HEAD~1
Drag options to blanks, or click blank then click option'
Acheckout
Breset
Ccommit
Drevert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'revert' instead of 'reset' for undoing commits locally.
2fill in blank
medium

Complete the command to create a new commit that undoes changes from a specific commit.

Git
git [1] <commit-hash>
Drag options to blanks, or click blank then click option'
Areset
Bmerge
Ccheckout
Drevert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reset' which rewrites history and can cause issues in shared branches.
3fill in blank
hard

Fix the error in the command to undo the last commit and discard changes in working directory.

Git
git [1] --hard HEAD~1
Drag options to blanks, or click blank then click option'
Areset
Brevert
Ccommit
Dstash
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'revert' which does not discard working directory changes.
4fill in blank
hard

Fill both blanks to create a new commit that undoes the last commit and pushes it to remote.

Git
git [1] HEAD~1 && git [2] origin main
Drag options to blanks, or click blank then click option'
Arevert
Breset
Cpush
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reset' before push which rewrites history and can cause conflicts.
5fill in blank
hard

Fill both blanks to reset the branch to the previous commit and force push to remote.

Git
git [1] --hard HEAD~1 && git [2] origin main --force
Drag options to blanks, or click blank then click option'
Areset
Brevert
Cpush
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using revert instead of reset for history rewrite.
Forgetting --force when pushing after reset.