LoginSignup
20
11

More than 5 years have passed since last update.

git reset --hard の復元

Posted at

やらかした

git reset --hard [コミットID]
ローカルコミットをファイル(変更箇所)毎消しちゃった。。。

落ち着いて確認

これでgitのログを確認。戻りたい履歴のHEAD@{*}の番号を確認する。
git reflog

復元

git reset --hard "HEAD@{1}"

HEAD@{1}の「{1}」はgit reflogで確認した戻りたい履歴の番号を入れる。

20
11
2

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
20
11