a, how to revert it back

Possible Duplicate:
Git undo last commit

After using git commit , how can I discard this commit and revert to my original state?


git reset HEAD^ will undo the last commit, and the changes you made in that commit will be unstaged but still remain.

git reset HEAD^ --hard will undo the commit and delete the changes made in the last commit.

Likewise, git reset HEAD^^ will go back 2 commits.

The Git Community Book is a great reference for learning to use git.


You can "undo" a commit like this using:

git reset HEAD^

The files that you changed in the commit will remain modified in your working directory (see git status ). If you use git reset --hard HEAD^ , then the changes you made in the most recent commit will additionally be discarded.


If you want to discard all changes with no way of going forward, use:

git reset --hard HEAD

Over here, HEAD is the ID of any of your previous commits. To roll back just one commit, get the commit id using:

git log

And then use:

git reset --hard 13cca2414skfrrrereaaa

13cca2414skfrrrereaaa - is what the commit id might look like.

链接地址: http://www.djcxy.com/p/576.html

上一篇: 如何撤消对GitHub仓库的提交?

下一篇: a,如何恢复它