6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.となった時の対応方法

Posted at

事象 : リポジトリ作成後に初回addを取り消そうとしたら怒られた

  • 環境
    • Windows10 64bit バージョン1909
    • git version 2.25.0.windows.1
  1. リポジトリを作成
  2. 初回add
  3. あっ・・・いらないものまでaddしちゃったから取り消そう
$ git reset HEAD .
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

原因 : HEADがないから

そりゃそうだ・・・で、どうしたらaddを取り消せるのか・・・

HEAD
最新コミットのスナップショットで、次は親になる
Git - リセットコマンド詳説

対応 : なにも指定しないでgit reset

参考 : 初心者のGitメモ

$ git reset

# おぉぉ、戻ったぁ
$ git status
On branch master

No commits yet

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

nothing added to commit but untracked files present (use "git add" to track)

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?