git 压缩提交

示例

将最近几个提交合并成一个提交

git rebase -i HEAD~[number_of_commits]

然后进入交互式选择

#
# 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
#
# 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.
#
# Note that empty commits are commented out

这里先进行 commit 方面的选择,这里最近的两次提交为 squash

pick f7f3f6d changed my name a bit
squash 310154e updated README formatting and added blame
squash a5f4a0d added cat-file

然后进行 commit msg 的界面,自己写一下合并后的 commit。

参考:

pro git

发表评论

电子邮件地址不会被公开。 必填项已用*标注