How to replace N
This question already has an answer here:
git stash -u # save uncommitted changes
git reset --soft HEAD~9 # move back 9 commits
git commit # recommit them
git stash pop # restore uncommitted changes
要将结果返回给GitHub,请确保您的本地副本在操作之前是最新的,并强制执行: git push -f
。
Do an interactive rebase:
git rebase -i HEAD~9
You will be put into an editor with a list of the last 9 commits, in chronological order. Each starts with the word 'pick'. You can change any of these to 'squash' or 's', to squash it into the previous commit. You will be given a chance to edit the commit message of the squashed commit. By default this will be the commit message of all the commits concatenated together.
You can also delete commits, replace 'pick' with 'reword' to be given a chance to change the commit message, 'edit' the commit as well as the message, etc.
Interactive rebase is very powerful so it's worth learning to use it.
Use squashing: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
Squashing lets you "squash" multiple commits into one commit. So basically your 9 commits will become one commit.
链接地址: http://www.djcxy.com/p/49036.html上一篇: 在Git上将一组提交合并为一个
下一篇: 如何取代N