git 版本回滚


1、克隆代码到本地

git clone http://qtools@dev.qtoolsbaby.cn:81/gitlab/qtools/jenkins_ceshi.git

2、git log 查看所有的历史版本

commit f0f1efe5837ed4bf6209c6152562902565e49f21
Author: ***  <tch@qtoolsbaby.com>
Date:   Fri Nov 3 01:26:38 2017 +0800

    d

commit 476791f298a14fd03c2fc415ebf79ef80443caed
Author: ***  <tch@qtoolsbaby.com>
Date:   Fri Nov 3 01:20:24 2017 +0800

    ceshi

commit 9a619ca0d1b3f5f14724075eb2ee84bf083afdb4
Author:***  <tch@qtoolsbaby.com>
Date:   Fri Nov 3 01:03:53 2017 +0800

    dd

commit 7efddfe4572d43d2e480edee41f7ff5910299e1d
Author: *** <tch@qtoolsbaby.com>
Date:   Fri Nov 3 00:57:57 2017 +0800

    修改


git log可以获取到某个历史版本的id,以及代码提交人,利用此id进行回滚,比如f0f1efe5837ed4bf6209c6152562902565e49f21
3、git reset --hard id

git reset --hard  f0f1efe5837ed4bf6209c6152562902565e49f21


id就是git log查看的所要回滚的版本id,这样就可以回滚到自己想要的之前版本

原文地址:https://www.cnblogs.com/tchua/p/7802991.html