GIT-Reflog

1、git reflog : 查看操作记录

$ git reflog
c1c1b21 HEAD@{0}: commit (amend): add blank line to index.html
9ff821d HEAD@{1}: commit: add blank line to index.html
b078331 HEAD@{2}: commit: no more commit!
b86e902 HEAD@{3}: commit: so many commit
77e6ce9 HEAD@{4}: commit: this is another commit
ccde039 HEAD@{5}: commit: this is a commit
a49dcf4 HEAD@{6}: clone: from ssh://[email protected]:29418/git_test.git

2、撤销某次记录

git reset --soft HEAD@{1} 撤销到暂存区
git reset --hard HEAD@{1} 干掉这个修改

// 撤销上次commit amend操作
$ git reset --soft HEAD@{1}

// 查看状态, 发现 amend 的内容已经被撤销 (到工作区) 了
$ git status
On branch master
Your branch is ahead of 'origin/master' by 5 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)


    modified:   index.html

你可能感兴趣的:(GIT-Reflog)