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?

More than 3 years have passed since last update.

Gitのコミットコメントを間違ってPushした際に修正する方法

Posted at

経緯

チームの方針でgitのコメントにEmoji Prefixをつける方針になったのだが、慣れていないためよく忘れてしまう
何回か今後もやらかしそうなのでやり方まとめておく

方法1

①コメントを修正する
②強制オプション付きでPushする

これが一番簡単です

コメントを修正する

直前のコミットの場合は下記のコマンドで修正できます

git commit --amend "修正後のコメント"

それ以前のコメントを変更したい場合は、こちらをご参考ください

強制オプション付きでPushする

git push -f

これで終わりです
ただ、強制的に自分の変更をリモートに反映させることになるので、実行時は細心の注意を払ってください
※共有ブランチでこの作業は絶対しないこと

方法2

上記が難しいケースはこちら

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?