LoginSignup
4
5

More than 5 years have passed since last update.

git コミットログの書き換え

Posted at

コミットログの書き換え

git commit --amend

revision が書き換わるので注意。

commit 7825f0fa9e89704be8859442a6590c89672019a2
aaa
commit 439cff3d94444685579e2e0b6a9fd8325ce4f3f7
bbb

コミットの所有者(メールアドレス)と日付の書き換え

git commit --amend --reset-author

コミットログのまとめ

git rebase -i HEAD~

して、エディタでまとめたいコミットを fixup or squash を選択

fixup はコミットログを削除
squash はログを書き換えられる

autosquash

コミットログの先頭に fixup! または squash! をつけておき、まとめたいコミットと
同じコミットログをかいておく。

git rebase -i HEAD~ --autosquash

で、コミット選択画面で自動的に squash または fixed を指定できる

git config --global --add rebase.autosquash true

で、rebase -i のときに自動的に --autosquash をつけてくれる。

なお、コミットするときに --fixup または --squashをつけると対象のコミットのメッセージをコピー+先頭に fixup! または squash! をつけてくれる。

直前のコミットとまとめたいのならば

$ git commit --fixup=HEAD
$ git rebase -i HEAD~ --autosquash
4
5
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
4
5