git reset
1.
Now take a second to look at that diagram and realize what it did. It essentially undid the last commit you made. When you run git commit
, Git will create a new commit and move the branch that HEAD
points to up to it. When you reset
back to HEAD~
(the parent of HEAD), you are moving the branch back to where it was without changing the Index (staging area) or Working Directory. You could now do a bit more work andcommit
again to accomplish basically what git commit --amend
would have done.
2.
Now take another second to look at THAT diagram and realize what it did. It still undid your last commit
, but also unstaged everything. You rolled back to before you ran all your git add
s AND git commit
.
3.
Finally, take yet a third second to look at that diagram and think about what happened. You undid your last commit, all the git add
s, and all the work you did in your working directory.