1. Soft reset
reset --soft moves HEAD back one commit but keeps that commit's changes staged.
git reset --soft HEAD~1Typorithm · hard
Step 1 of 8 · intro card
Advanced
reset --soft moves HEAD but keeps changes staged; --hard discards them (destructive). revert creates a NEW commit that undoes a commit, safe for shared history. reflog records where HEAD has been, so you can recover lost commits by resetting to HEAD@{n}.
git reset moves the current branch to point at a different commit. --soft HEAD~1 rewinds one commit but keeps that commit's changes staged, ready to recommit. --hard HEAD~1 rewinds and throws the changes away entirely — destructive and unrecoverable through normal means.
git revert HEAD takes a different approach: instead of rewriting history it adds a NEW commit that applies the inverse of HEAD. Because it never rewrites existing commits, revert is the safe way to undo something already pushed to a shared branch.
git reflog is your safety net. It logs every position HEAD has occupied, addressable as HEAD@{0}, HEAD@{1}, HEAD@{2}, and so on. If a reset or rebase loses a commit, find it in the reflog and git reset --hard HEAD@{2} brings the branch back.
reset --soft keeps changes staged; --hard discards them.
revert adds a new commit — safe for shared history.
reflog tracks HEAD so you can recover lost commits.
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert HEAD
git reflog
git reset --hard HEAD@{2}Connect each part of the code to the concept before you type.
reset --soft moves HEAD back one commit but keeps that commit's changes staged.
git reset --soft HEAD~1reset --hard moves HEAD and discards the changes — a destructive operation.
git reset --hard HEAD~1revert creates a new commit that undoes HEAD, safe for shared history.
git revert HEADreflog lists every position HEAD has been at, letting you find lost commits.
git reflogHEAD@{2} is where HEAD was two moves ago; resetting to it recovers that state.
git reset --hard HEAD@{2}Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.