赞
踩
请在你的git bash输入如下命令,此时会在你的浏览器弹出一个关于git reset详解的html页面。其实这个html就在你的本地,顺腾摸瓜,可以在此路径下面找到其它的一些命令教程。
git reset --help
暂且只讨论下面的用法,soft,mixed,hard。请将下面的英文解释多看几遍,可以自行google翻译。
- git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
-
- --soft
- Does not touch the index file or 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.
-
- --mixed
- Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
-
- If -N is specified, removed paths are marked as intent-to-add (see git-add(1)).
-
- --hard
- Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.
理解上图中的关系,多看几遍英文解释,多动手操作几遍。下面是我的理解。
hard:将HEAD之后的变更内容全部丢弃。
mixed:将HEAD之后的变更内容放到工作区中
soft:代表将HEAD之后的变更内容放到暂存区中。
以下下三个图均在我当前HEAD中,将test.txt添加到了暂存区,但是没有提交的条件下执行的。不用关注我过程修改的内容,你只需要关注当我执行了mixed/soft/hard之后,使用git status查看的状态。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。