LoginSignup
5
2

More than 5 years have passed since last update.

Gitで直前のコミットをなかったことにする

Posted at

まず確認

まずは取り消したい直前のコミットをチェック。

$ git log

PhpStormを使ってるのならversion controlのLogを見た方がわかりやすいかも。

取り消す

取り消したいコミットを確認できたら

$ git reset HEAD^

これで戻る。

うまくいったか確認

$ git status -s

PhpStormならversion controlでチェックできる。
直前のコミットが取り消され、かつ自分の手元のファイルの作業状態は維持されたままになる。

やっていること

直前のコミットで1枝進んでしまったbranchを1つ戻し、新しい枝を生成し直している、らしい。

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