2
1

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 3 years have passed since last update.

Push済みのコミットのコメントを変更する方法

Posted at

概要

リモートへPushしてしまったコミットのコメントを変更する方法を記載する。

手順

変更したいコミットを指定する

指定した数値分、現在の状態から前のコミットを見ることができる
以下のようにすると3個前のコミットまで見ることができる。

$ git rebase -i HEAD~3 // 数値は可変

変更したいコミットを選択

コミットの一覧がpick ~ コミットコメントという形で表示されるので、変更したいコミットのpickeditに書き換えて保存する。

コミットコメントの編集

以下のコマンドでコミットコメントが変更できるようになるので、任意のコミットコメントに編集し保存する。

$ git commit --amend

コミットコメントの編集終了

以下のコマンドでコミットコメントの編集を終了する。
※変更したいコミットが複数ある場合、1つ前の手順に戻り手順を繰り返す。

$ git rebase --continue

リモートにPushする

強制的にPushを行う。
以下のようにするとmasterにPushすることができる。

$ git push -f origin master // ブランチ名は可変
2
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?