合并最近的 N 个 commits
执行 rebase 命令
1 | git rebase -i HEAD~N |
终端会打开一个编辑器:
1 | pick a1b2c3 commit message 1 |
第一个词有三个选项:
pick保留 commitsquash合并到上一个 commit,保留 messagefixup合并,但是丢掉 message
例如说可以改成这样
1 | pick a1b2c3 commit message 1 |
保存退出后,git 会让你编辑最终的 commit message.然后最终呈现的就是单个 commit
1 | a1b2c3 some new combined commit |