0
0
Gitdevops~10 mins

Recovering from hard reset in Git - Interactive Code Practice

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

Complete the command to view the reflog and find the commit before the hard reset.

Git
git [1]
Drag options to blanks, or click blank then click option'
Astatus
Bdiff
Creflog
Dlog
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'git log' only shows current branch commits, not reflog history.
Using 'git status' does not show commit history.
2fill in blank
medium

Complete the command to reset the branch to the commit before the hard reset using its hash.

Git
git reset --hard [1]
Drag options to blanks, or click blank then click option'
Acommit_hash
BHEAD~1
Corigin/main
Dmaster
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'HEAD~1' may not point to the correct commit after a hard reset.
Using branch names like 'master' or 'origin/main' resets to latest remote or branch tip.
3fill in blank
hard

Fix the error in this command that tries to recover the commit before the hard reset.

Git
git reset --hard [1]
Drag options to blanks, or click blank then click option'
AHEAD@{1}
BHEAD^2
CHEAD~2
DHEAD^^
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'HEAD^2' or 'HEAD^^' refers to parent commits, not reflog positions.
Using 'HEAD~2' moves two commits back, which may not be correct after reset.
4fill in blank
hard

Fill both blanks to create a command that shows the commit message and hash from reflog for the last 3 entries.

Git
git reflog --pretty=format:'%[1] %[2]' -n 3
Drag options to blanks, or click blank then click option'
Ah
Bs
CH
Dan
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'H' shows full hash, which is longer.
Using 'an' is not a valid placeholder.
5fill in blank
hard

Fill all three blanks to create a command that recovers the last hard reset commit and forces push to remote.

Git
git reset --hard [1] && git push [2] [3] --force
Drag options to blanks, or click blank then click option'
AHEAD@{1}
Borigin
Cmain
Dmaster
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'master' instead of 'main' if the repository uses 'main' branch.
Forgetting to use --force when pushing after reset.