0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[備忘録] git revert -m 1/2どっちだ?

Posted at

はじめに

git revertするときに、-m 1なのか-m 2なのか分からなくなったので勉強し直したメモ。

[結論] 基本的に以下のコマンドでヨシ
git revert -m 1 <merge commit id>

数字の意味とは

revertしたいときは、何かしら悪さをするコミットがあるとき。
件の悪さをするコミット(以下、邪魔コミット)の視点で考えるとイメージしやすい。

-m 1 のとき

邪魔コミットが自分から離れるイメージ。
作業中のメインストリームにて、自身由来の問題が発生したとき「あ、これ自分が邪魔してるな。離れよ」という感じ。
殆どのケースはこれ。

-m 2 のとき

邪魔コミットを突き放すイメージ。
作業中のメインストリームにて、自身由来の問題が発生したとき「大変だねアンタら。……え?私が追放されるんですか?」という感じ。
他ブランチを取り込んで何かしたときに邪魔になって/不要になって切り離したいときに使う。
レアケース。

0
0
4

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?