reset: move a branch back
Lesson 22 of 24 · Git.Micro
git reset moves the current branch to another commit. The commits after it leave the branch, and the options decide what happens to your files.
--soft keeps every change staged; --mixed (the default) keeps them unstaged; --hard throws them away.
HEAD~3 means three commits before HEAD: git reset --soft HEAD~3 + a commit squashes three commits into one.
Went too far? git reflog lists where HEAD has been, so git reset --hard HEAD@{1} undoes the reset.
Check yourself
Which reset throws away your changes?
The last three commits are all called wip. Squash them into a single commit Add photo gallery, keeping exactly the same final files.
Do it in the browser: a real Git tool, a short mission and instant feedback. No install.
Start this lesson — free