memorandum

IT技術の習得を記録します

コミットをまとめる

git rebase -i --keep-empty --autosquash $(git show-branch --merge-base master HEAD)

vimに以下のような状態で開かれる

pick 05eb1e4 test2rb
pick 7dc17cc add test.rb

# Rebase 7802bc5..7dc17cc onto 7802bc5 (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#

pickの部分を以下のように変更 (まとめたいコミットをpick→fにかえる) 一行目は残しておくのでpickのまま

pick 05eb1e4 05eb1e4 test2rb
f 7dc17cc add test.rb

vimで直前のコミットメッセージを修正

git commit --amend
git push --force-with-lease