LoginSignup
110

More than 5 years have passed since last update.

posted at

updated at

【Git】間違ってpushした場合の取り消し方

ローカルでrevertを使って取り消して、それをリモートへ反映する。

revertは相殺で取り消すのでログからは消えない。(正確には取り消しではなくて打消し)
resetだとログから完全に消えていまい危険なのでrevert推奨らしい。

1.取り消したいコミットのコミットIDを取得する。

$git log 
commit XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Author: Foo Bar <XXX@XXXX>
Date:   Tue Mar 15 10:26:14 2016 +0900

    XXXを修正

2.取り消したいコミットをrevertする。
複数のコミットを消したい場合はこれが複数になるだけ。

$git revert <commit id>

3.リモートへpushする

$git push

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
What you can do with signing up
110