5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ブランチ間違ったままでリモートリポジトリにpushしちゃった時

Posted at

correct_branchに 間違ったコミットその1, 間違ったコミットその2 の変更を適用したつもりが、wrong_branch にコミットした上にpushまでやっちゃったときにやったこと

git checkout wrong_branch
git log -3
commit 12345
Author: xxx
Date:   xxx

    間違ったコミットその2

commit 67890
Author: xxx
Date:   xxx

    間違ったコミットその1

commit abcde
Author: xxx
Date:   xxx

    ここまで戻したいコミット

git checkout correct_branch
git cherry-pick 67890
git cherry-pick 12345
git push
git checkout wrong_branch
git revert 12345
git revert 67890
git push
5
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?