LoginSignup
1
1

More than 3 years have passed since last update.

不要なものをpushしてしまった時に戻す方法

Posted at

取り消したいcommitのハッシュ値を確認

$ git log --oneline

以下のコマンドで「commitを取り消すcommit」を作成

$ git revert <取り消したいcommitのハッシュ値>

この瞬間にすでに,add,mergeは実行されているので、あとはpushするだけ

$ git push origin develop

特定のcommitの特定のファイルのcommitだけ打ち消したい時

基本的には、ここにある通りです。

まずは、git logに戻したいファイル名を指定し、特定のファイルのコミットログのハッシュ値を確認

$ git log ファイル名(相対パス)

次に、以下のコマンドで、ファイルをそのコミットログのハッシュ値の場所まで戻す

$ git checkout ハッシュ値 ファイル名(相対パス)

この場合、このあとは、commitしてからpushしたらOK.

1
1
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
1
1