git rebase・squash
rebase
今までのコミットしてきたものの上にmasterのコミットをポンっと置くイメージ。
rebaseするときは一旦新たにブランチを切ってから行うべし。
squash
コミットを一つにまとめる
squashの流れ
コマンドでコミットのログを見る
git log --oneline
を叩くと、
nanako:gtest nanako$ git log --oneline a0de58f last commit 1574f49 sample3 17a75e7 sample2 6b45ec9 sample1 791c07e first commit
sample1、sample2、sample3をcommit all
としてコミットをまとめるとすると、
git rebase -i 791c07e
を叩くと、下のものが出てくる。
pick 6b45ec9 sample1 pick 17a75e7 sample2 pick 1574f49 sample3 pick a0de58f last commit
sample2とsample3のpick
の部分をs
に変更して上書き保存。
コミットのメッセージが表示されるので、first commit's message is
に描かれているsample1
を消して、commit all
と書いて上書き保存。
再度コミットのログを確認
git log --oneline
a0de58f last commit 84yeu43 commit all 791c07e first commit