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でよく利用するオプション2選

0
Posted at

はじめに

git revert を使う際に、個人的によく使うオプションを2つメモとしてまとめておきます。

-m オプション

マージコミットを revert する場合、どちらの親を基準にするか指定する必要があります。
その際に利用するのが -m オプションです。

git revert -m 1 <merge_commit_hash>

-mmainline を意味し、どの親を基準にするか指定します。

例:

git revert -m 1 abcdef123456
  • 1 → 1番目の親(通常はマージ先ブランチ)
  • 2 → 2番目の親(マージ元ブランチ)

マージコミットをrevertする際には、ほぼ必ず使うことになるオプションです。

--no-edit オプション

git revert を実行すると、通常はコミットメッセージの編集画面が開きます。

git revert <commit_hash>

これをスキップしたい場合は --no-edit を付けます。

git revert --no-edit <commit_hash>

これにより、デフォルトのメッセージでそのままコミットされます。

環境

  • git version 2.43.0
0
0
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
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?