git undo redo

基础:

git三个区(本地):

(1)     工作区(working directory)

(2)     暂存区(stage, index)

(3)     仓库(repository)

 

·       Un-do

(1)撤销add操作

将加入Stage中的文件(gitstatus绿色)取出放到WorkingDir中(红色)

git reset Head [path]

eg:将所有add后,并在stage中的文件都取出(gitstatus显示绿色的所有文件都变红色)

git reset Head *

 

(2)撤销修改

 文件修改后,git status变红,使用git checkout -- [path]可撤销被修改的文件内容(文件内容直接回到被修改前)

文件修改后,git status变红;或修改后被add,变绿。使用git reset Head --hard, 文件内容直接回到被修改前

 

·        Difference

git reset is specifically about updating the index, moving the HEAD.

 

git checkout is about updating the working tree (to the index or thespecified tree). It will update the HEAD only if you checkout a branch (if not,you end up with a DETACHED HEAD).
--------------------- 
作者:ybdesire 
来源:CSDN 
原文:https://blog.csdn.net/ybdesire/article/details/22665427 
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值