reverse_xiaoyu

忘记并不可怕,可怕的是你从来就都不知道!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

git 如何撤销 commit (未 push)

  撤销 commit 一般用 git reset ,语法如下:

1 git reset [ --mixed | --soft | --hard] [<commit ID>]

 

  1.使用参数--mixed(默认参数),如git reset --mixed <commit ID>或git reset <commit ID>

    撤销git commit,撤销git add,保留编辑器改动代码

  2.使用参数--soft,如git reset --soft<commit ID>

    撤销git commit,不撤销git add,保留编辑器改动代码

  3.使用参数--hard,如git reset --hard <commit ID>——此方式非常暴力,全部撤销,慎用

    撤销git commit,撤销git add,删除编辑器改动代码

如果嫌输出信息太多,可加上--pretty=oneline参数,即 

1 git log --pretty=oneline

 

posted on 2020-12-07 19:54  Reverse-xiaoyu  阅读(450)  评论(0编辑  收藏  举报