两种情况:
1合并已经提交到远程的commit:
1)git rebase -i HEAD~3
2)第一个选pick,其他都改为 s 或 squash
s为压缩的commit信息,可以将其 全部删除。
在pick的那个上,修改为描述这 3 个全部的信息
3)修改后保存退出,这时 git log 一下,发现提交已经合并
合并后的效果:
本来是 add b.php add c.php add d.php 3次
现在合并到一起了,一次。
https://www.jianshu.com/p/4a8f4af4e803
4)push上去 git push -f
这样才能在远程体现
https://blog.youkuaiyun.com/qq_21744873/article/details/82629343
2.合并还没push到远程的
https://segmentfault.com/a/1190000007748862
3.合并上次提交
git commit --amend -m "xxx"
这样就会把上次的提交覆盖,提交信息也会变为"xxx"
https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%92%A4%E6%B6%88%E6%93%8D%E4%BD%9C
参考链接
https://segmentfault.com/a/1190000007748862
https://blog.youkuaiyun.com/qq_21744873/article/details/82629343