git合并多次提交记录

命令

git rebase -i HEAD~4

或者

git rebase -i bddesdd6 #要合并的提交的上一条提交ID

合并(vi编辑器模式)

pick bddebfb1 退出修改
f 68326b8c 接口修改
f 699501f7 接口修改
f 784e86b3 接口修改

# Rebase 2b8d14b7..784e86b3 onto 784e86b3 (4 commands)
#
# Commands:
# p, pick  = use commit
......

主要看这里的合并方式
根据描述 用f(fixup) (使用这个提交,但合并到前一个提交,并且忽略备注)

# 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
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop  = remove commit
# l, label 

如果中途发生异常,比如还没完成关闭了终端,可随时中断重新rebase

git rebase --abort

同步到远程(确保此分支没有别的提交或者只有你在用)

git push origin branchName -f

你可能感兴趣的:(git)