Loading

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 addAND 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 adds, and all the work you did in your working directory.


posted @ 2012-04-01 21:19  .net's  阅读(330)  评论(0)    收藏  举报