git命令

本文详细介绍了Git中reset命令的不同用法,包括如何回退到指定版本,并保持或丢弃改动,以及如何彻底删除通过reset --hard丢弃的提交。这对于理解和操作版本控制非常有用。

git reset --soft fd35h567 (fd35h567表示git log看到的提交号)

           --soft
               Does not touch the index file nor the working tree at all (but resets the head to <commit>, just
               like all modes do). This leaves all your changed files "Changes to be committed", as git status
               would put it.

    作用: 将版本fd35h567之前的提交都置为未提交,在本地可以看到未提交的代码。

 

git reset --hard fd35h567

           --hard
               Resets the index and working tree. Any changes to tracked files in the working tree since
               <commit> are discarded.
             作用: 将版本fd35h567之前的提交都丢弃

 

git stash pop

            将git reset --hard fd35h567丢弃的提交彻底删除

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值