最近 git rebase -i
がの便利な機能を知ったのでメモとして残します。
今の git log
の状態
commit cd8a4309b4e196d3fc169f10b708197c48898346
Date: Tue May 21 09:01:15 2019 +0900
file modified
commit f9d702a3c0f6188c780609270da917aa174d858a
Date: Tue May 21 08:59:14 2019 +0900
modified file
commit 321f711dc4a590fd27721523d53a69353e9daf76
Date: Tue May 21 08:58:42 2019 +0900
created file
1つ目と2つ目のコミットをまとめたい。
git rebase -i HEAD~2
すると以下のようなvimが立ち上がります。
pick f9d702a modified file
pick cd8a430 file modified
ここで以下のようにすると
pick f9d702a modified file
s cd8a430 file modified
こんな感じでコミットメッセージを編集する画面が表示されます。
# This is a combination of 2 commits.
# This is the 1st commit message:
modified file
# This is the commit message #2:
file modified
しかし、こんな感じにすると
pick 0f1e189 modified file
f b470369 third commit
pick
されたコミットのメッセージが残ります。
少しだけ時短