Hi Thomas: Thank you for your reply.
I will try it. 在 2012年12月20日星期四UTC+8下午4时28分21秒,Thomas Ferris Nicolaisen写道: > > On Thursday, December 20, 2012 7:25:19 AM UTC+1, Wei Alex wrote: > >> Hi,All: >> >> I need to merge multiple special commits to one.Please help me. >> For example, I have some commits like this: >> A->B->C->D->E. >> Some of these were commited by me. I want to select them and merge >> them to one commit just like A->C->E.The new commit A include the commit A >> B and D. >> >> Now I knew one method to merge multiple commits to one. >> * git resest --soft HEAD^n* >> * **git commit --amend* >> BUT this method can just merge the TOP n commit not the special ones. >> Please tell me how can I finish this work.Thanks. >> >> > > Rebase interactive is your friend: > http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages > > In essence: > > git rebase -i A > # reorder the commits so that the ones you want to squash together are > right after one another > # squash up the commits > > Remember, if you have already shared or published this history you should > NOT rewrite/rebase it any more. > --