LoginSignup
1
0

More than 1 year has passed since last update.

[Git] コミットの整理をしよう

Last updated at Posted at 2022-10-22

開発ブランチで開発を進めているときにバグが見つかることがあると思います。

Screen Shot 2022-10-22 at 12.53.52.png

こう行った時の整理方法をここに書いていきます。

git rebase -iでfixupする

git rebase -i を使いfixupコマンド(f)を使うことで、直前の pick となっている commit に統合することができます。

Screen Shot 2022-10-22 at 13.07.00.png

git rebase -i --autosquash

バグの修正をした時、git commit --fixup 一緒にしたいターゲットコミットのハッシュとします。

すると、fixup!と頭についたコミットメッセージが生成されます。

Screen Shot 2022-10-22 at 13.50.52.png

そしてgit rebase -i --autosquashを実行すると先程のコミットに fixup コマンドが付与された状態でエディタが開かれます。

Screen Shot 2022-10-22 at 14.02.32.png

あとはそのままリベースするだけです。

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