Gitの取消し・削除系のコマンドが、ワークツリー・インデックス・HEADのいずれに作用するかをまとめました。
# | コマンド | ワークツリー | インデックス | HEAD |
---|---|---|---|---|
1 | git checkout . | ○ | - | - |
2 | git rm [file] | ○ | ○ | - |
3 | git rm [file] --cached | - | ○ | - |
4 | git reset --soft HEAD^ | - | - | ○ |
5 | git reset --mixed HEAD^ | - | ○ | ○ |
6 | git reset --hard HEAD^ | ○ | ○ | ○ |
7 | git restore --worktree file | ○ | - | - |
8 | git restore --staged file | - | ○ | - |