3
1

More than 1 year has passed since last update.

SourceTree(ソースツリー)| revert(リバート)| コミットを打ち消し

Last updated at Posted at 2022-07-04

revert(リバート)とは

Git:リポジトリ内で行われたコミットを打ち消す処理
英語:立ち戻る、戻る、復帰する

SourceTree のやり方

コミット履歴の一覧から打ち消したいコミットを選択して、右クリックから「このコミットを打ち消し」を選択する

コマンドのやり方

※注意:SourceTree では merge コミットの revert は できない

マージコミットの revert で発生するエラー

no -m option was given.
▼
-mオプションが指定されていない

マージしたコミットの場合は、親が2つあるので、親を指定しないと revert できずエラーが表示されるので、戻したいコミットIDの前に「-m 1」OR「-m 2」を指定してあげる

  • 親1(-m 1):マージされるブランチマージ前コミット
  • 親2(-m 2)マージするブランチの先頭コミット
[コミット1234567を打ち消したい]
× git revert 1234567 ➡ 親の指定がない
● git revert -m 1 1234567 "コミットメッセージ" ➡ 親1の指定
● git revert -m 2 1234567 "コミットメッセージ" ➡ 親2の指定

image.png
※# Please enter the commit message for your changes. Lines starting
※# with '#' will be ignored, and an empty message aborts the commit.
とでたら…コミットメッセージを入力してあげましょう
「i」キー:入力モードに切り替え
変更履歴等の情報(メッセージ)を一番上に入力
「Esc」キー:コマンドモードに切り替え
「:wq」で保存、エディタを終了

参考

3
1
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
3
1