git reset --hard 之 git版本回退

学习笔记,参考:https://blog.csdn.net/themagickeyjianan/article/details/78923322

 

1.假设有2个提交记录

commit def5adef853da4cc05752bdb36577c127be71ba5

Author: 132982jianan <1072772483@qq.com>

Date:   Thu Dec 28 16:01:36 2017 +0800

 

    add data to 1.txt

commit f36801544670e00b2f59a28e19017d2786c4085e
Author: 132982jianan <1072772483@qq.com>

Date:   Thu Dec 28 15:59:46 2017 +0800

 

    init 1.txt
(END)

2.现在回到最开始的那一个提交
git reset --hard f36801544670e00b2f59a28e19017d2786c4085e

3.查看日志,就会发现只剩下一个提交了
git log

commit f36801544670e00b2f59a28e19017d2786c4085e
Author: 132982jianan <1072772483@qq.com>
Date:   Thu Dec 28 15:59:46 2017 +0800

    init 1.txt
(END)


4.这个时候,发现回退版本错了,那么就用git reflog查看提交记录
git reflog

f368015 HEAD@{0}: reset: moving to f36801544670e00b2f59a28e19017d2786c4085e
def5ade HEAD@{1}: reset: moving to def5ade
f368015 HEAD@{2}: reset: moving to f36801544670e00b2f59a28e19017d2786c4085e
def5ade HEAD@{3}: commit: add data to 1.txt
f368015 HEAD@{4}: commit (initial): init 1.txt

 

5.找出想要回退的版本,进行回退

恢复

git reset --hard def5ade

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值