How do you squash commits into one patch with git format-patch?

前端 未结 8 1101
無奈伤痛
無奈伤痛 2020-11-30 16:58

I\'ve got eight commits on a branch that I\'d like to email to some people who aren\'t git enlightened, yet. So far, everything I do either gives me 8 patch files, or start

8条回答
  •  日久生厌
    2020-11-30 17:22

    As you already know, a git format-patch -8 HEAD will give you eight patches.

    If you want your 8 commits appear as one, and do not mind rewriting the history of your branch (o-o-X-A-B-C-D-E-F-G-H), you could :

    git rebase -i
    // squash A, B, C, D, E ,F, G into H
    

    or, and it would be a better solution, replay all your 8 commits from X (the commit before your 8 commits) on a new branch

    git branch delivery X
    git checkout delivery
    git merge --squash master
    git format-patch HEAD
    

    That way, you only have one commit on the "delivery" branch, and it represent all your last 8 commits

提交回复
热议问题