0
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 resetを2回やってunknown revision or path not in the working tree.と出た時の対処法

Last updated at Posted at 2022-06-12

今すぐに2回目のresetをしたい人向け。本質的な解決方法ではないです。

起きたこと

1回目のgit reset --hard HEAD~xxはできたが、2回目をすると以下のエラーが出た。

fatal: ambiguous argument 'HEAD~xx': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

HEAD~xxという引数が曖昧だと言っている。

じゃあid指定しよう

git reflogの一番左に表示されるIDを引数に渡せば流石に曖昧じゃないだろう、と思い実行すると成功した。

$ git reflog
...
e1499887 HEAD@{15}: commit: docker化した
$ git reset --hard e1499887
HEAD is now at e1499887 docker化した

参考

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