git reset --hard

  • git reset -–hard彻底回退到某个版本,本地的源码也会变为上一个版本的内容,撤销的commit中所包含的更改被冲掉

比如想将当前本地代码重置到commit b96b56fd057bfff9fd0e52d635f4d50064f5a782

$ git log
commit 1723ef5eb15682302d3ef3486da73a5ed7bf3252 (HEAD -> feature, tag: v1.0.0, origin/master, origin/feature, master)
Author: xxx<xx.com>
Date:   Sun Jul 19 22:51:27 2020 +0800

    add

commit b96b56fd057bfff9fd0e52d635f4d50064f5a782
Author: xxx<xx.com>
Date:   Sun Jul 19 17:32:30 2020 +0800

    5_iconeditor

commit 79835af0c4fe9176e2c77e4d2c1408d53cf6c87f
Author: xxx<xx.com>
Date:   Sun Jul 19 14:36:13 2020 +0800

    HexSpinBox

需要

$ git reset --hard  b96b56fd057bfff9fd0e52d635f4d50064f5a782
HEAD is now at b96b56f 5_iconeditor

如果里面还有子模块,还需要

git submodule update --init

猜你喜欢

转载自blog.csdn.net/LIJIWEI0611/article/details/108365351
今日推荐