开发者

How can I combine two non-sequential git commits into one? [duplicate]

开发者 https://www.devze.com 2023-02-17 15:43 出处:网络
This question already has answers he开发者_开发知识库re: How do I squash two non-consecutive commits?
This question already has answers he开发者_开发知识库re: How do I squash two non-consecutive commits? (5 answers) Closed 9 years ago.

If the following is a list of commits on a branch:

A - B - C - D

How can I combine commits A and C into (AC)?

(AC) - B - D


First do git rebase -i aaaaaa^ and then your text editor will show up looking like this:

pick aaaaaa
pick bbbbbb
pick cccccc
pick dddddd

Change it so that it looks like

pick aaaaaa
squash cccccc
pick bbbbbb
pick dddddd

and close it and git does the rest.

http://git-scm.com/docs/git-rebase


git rebase -i A^

edit them so that C is after A. Change the pick to f (fixup) and save.

0

精彩评论

暂无评论...
验证码 换一张
取 消