git squashing multiple commits into multiple commits

蹲街弑〆低调 提交于 2019-12-10 22:48:58

问题


In light of this:

Combining multiple commits before pushing in Git

suppose I have this rebase:

pick 16b5fcc msg1
pick c964dea msg3
pick 06cf8ee msg1
pick 396b4a3 msg2
pick 9be7fdb msg3
pick 7dba9cb msg2

Suppose I want to combine all comitts with the same message into one...(ie all msg1 commits into a single msg1 commit, all msg2 commits into 1 msg2 commit, etc)

How should I go about squashing these?


回答1:


git-rebase lets you reorder and squash commits. Something like this ought to work:

pick 16b5fcc msg1
squash 06cf8ee msg1
pick 396b4a3 msg2
squash 7dba9cb msg2
pick 9be7fdb msg3
squash c964dea msg3

If you have a lot of commits, I would suggest you write a script to group them as above.



来源:https://stackoverflow.com/questions/14146647/git-squashing-multiple-commits-into-multiple-commits

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!