[Git] git addを取り消す

git addを無かったことにします。

コマンド

$ git reset foo.txt

実行例

git reset [ファイルのパス] でキャンセルすることができます。

$ git add foo.txt
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   foo.txt

git resetするとUntracked fileとなり、git addする前の状態に戻りました。

$ git reset foo.txt
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        foo.txt

なお、git reset [ファイルのパス]git reset HEAD [ファイルのパス] と同じ意味になります。

参考