git reset用法 一 重置引用(版本切换)
reset命令让我们可以在历史版本中切换。每次commit都会有一个commit id。
比如看看我的仓库的日志:
$ git reset --hard HEAD@{1}HEAD is now at 1aea8d9 add test file x现在来看一下参数--hard,其实还有其他选项,默认选项是--mixed, 第三个选项是--soft.
--hard是最强的选项,将当前版本设置为某个历史版本后(通过修改引用文件/refs/heads/master来实现),staging和working area的内容也和那个历史版本完全一致。这就意味着你的某些文件可能就失踪了,像x文件一样。
--mixed是默认选项,它修改引用文件,不改变working area的文件,但是staging 内容已经和历史版本一致。
--soft是最弱选项,它只修改引用文件,不改变staging和working area的文件。