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

gitで過去のコミット時点に戻りたいとき

Posted at

変な変更をしてしまい、よくわからないエラーが出た。
間違えて上書きしてしまい、最新の状態でなくなったとき、過去のコミット時点に戻りたいと考えますよね。

下記のコードを実行するだけで解決です。

git log
=>commit 123456789
Author: Ubuntu <ubuntu@ip-172-31-19-168.ap-northeast-1.compute.internal>
Date:   Wed Feb 8 02:34:41 2023 +0000

git log をすると過去のコミットログが出てきます。
戻りたい地点のログを探し、commit の右側にある数字を控えます。

git reset --hard 123456789

控えた数字を、git reset --hard の後に入れるだけ。

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