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://liux@xxx.xx.xx.xxx: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 <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)


    modified:   index.html
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 查看、添加、提交、删除、找回,重置修改文件 git help # 显示command的help git sho...
    Swiftor阅读 2,138评论 0 2
  • 1. GIT命令 git init在本地新建一个repo,进入一个项目目录,执行git init,会初始化一个re...
    江边一蓑烟阅读 826评论 0 0
  • Git简介 Git是Linux之父Linus的第二个伟大的作品,它最早是在Linux上开发的,被用来管理Linux...
    Windy_816阅读 27,226评论 1 37
  • 简介 Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。 Git 与常用的版本控制工具 ...
    闽越布衣阅读 2,771评论 0 18
  • git作为时下最流行的代码管理工具,Git权威指南总结了十条喜欢Git的理由: 异地协同工作; 现场版本控制; 重...
    古斟布衣阅读 1,846评论 0 12