LoginSignup
22
21

More than 5 years have passed since last update.

プッシュ前のローカルのコミットを取り消す方法

Posted at

ローカル環境で途中の段階に戻って、コミットし直す方法についてです。
gitで変更点の履歴を参照する方法は

git log

で参照することができます。
このコマンドを使うと

  • commit ID(16進数で40桁)
  • Author
  • Date
  • comment

が表示されます。
このcommitIDを使用して取り消しを行います。
取り消しは、

git reset --hard <commitId>

でコミット地点を変更できます。
コミット地点に変更すると、当然ながら、変更前までの段階のファイルしか存在しません。
そのあたり、注意された方がいいと思います。

22
21
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
22
21