git reset HEAD 与 git reset --hard HEAD的区别
git reset HEAD 是将咱暂存区和HEAD的提交保持一致
git reset --hard HEAD 是将工作区、暂存取和HEAD保持一致
测试 git reset HEAD
1. 创建一个readme.md 的文件

2 创建一个commit 执行以下命令
git add -A
git commit -m "create readme.md test file"
查看提交
git log --all --graph --oneline

3 添加暂存取的文本

执行命令,保持到暂存取
git add -A
执行命令,比较暂存取和HEAD的区别
git diff --cached

4 添加工作区的的内容

执行命令,比较工作区和暂存取的不同
git diff

5 执行命令
git reset HEAD

比较工作区和暂存区的内容
执行命令
git diif

比较暂存取和HEAD的内容
执行命令
git diff --cached

发现暂区和HEAD没有区别
说明 git reset HEAD 会把暂存区恢复成HEAD
6
执行命令
git add -A
添加到暂存区
执行
git diff --cached

发现暂存区添加了两行内容
7
工作区添加一行文字

执行
git reset --hard HEAD

执行
git diff
git diff --cached
发现工作区、暂存区和HEAD没有区别

说明执行 git reset --hard HEAD 命令 会将工作区和暂存区恢复成HEAD