Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
84
Help us understand the problem. What is going on with this article?
@kazu56

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

More than 5 years have passed since last update.

ローカルで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
84
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kazu56

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
84
Help us understand the problem. What is going on with this article?