8
0

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 1 year has passed since last update.

[Git / windows] git reset HEAD@{n} すると error: unknown switch `e' が発生する

Posted at

症状

タイトルの通り。

私の場合こうなりました。

powershell
> git reset --hard HEAD@{12}
error: unknown switch `e'
usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]
   or: git reset [-q] [<tree-ish>] [--] <pathspec>...
   or: git reset [-q] [--pathspec-from-file [--pathspec-file-nul]] [<tree-ish>]
   or: git reset --patch [<tree-ish>] [--] [<pathspec>...]
   or: DEPRECATED: git reset [-q] [--stdin [-z]] [<tree-ish>]

    -q, --quiet           be quiet, only report errors
    --no-refresh          skip refreshing the index after reset
    --mixed               reset HEAD and index
    --soft                reset only HEAD
    --hard                reset HEAD, index and working tree
    --merge               reset HEAD, index and working tree
    --keep                reset HEAD but keep local changes
    --recurse-submodules[=<reset>]
                          control recursive updating of submodules
    -p, --patch           select hunks interactively
    -N, --intent-to-add   record only the fact that removed paths will be added later
    --pathspec-from-file <file>
                          read pathspec from file
    --pathspec-file-nul   with --pathspec-from-file, pathspec elements are separated with NUL character
    -z                    DEPRECATED (use --pathspec-file-nul instead): paths are separated with NUL character
    --stdin               DEPRECATED (use --pathspec-from-file=- instead): read paths from <stdin>

Environment

gitのバージョンは以下の通り

powershell
> git --version
git version 2.37.0.windows.1

対策

これだとダメなんですが、

powershell
> git reset --hard HEAD@{12}

こうするといけました。

powershell
> git reset --hard 'HEAD@{12}'

クォーテーション'で囲んであげればいいんですね。

終わりに

日本語の記事がなくて焦ったので記事化。
これって結構初心者でも躓くところだと思う。

とはいっても、初心者はgit reflog使わないか。。。

参考にした記事

8
0
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
8
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?