合并/删除多个commit
2021-05-25 本文已影响0人
DOB_8199
参考文档:https://juejin.cn/post/6844903600976576519

如图出现了多个commit如何合并成一个:
1. git log 找到这两个commit的版本号(马赛克的地方)

2. git rebase -i HEAD~2
rebase从head往下数两个(进去之后可以改版本号,所以这里你需要改几个就写几个)
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
如果要移除,必须有一个pick,否则会移除该分支所有提交!!!(基本所有操作都需要有一个版本号在pick命令上)