Cookiewill
Cookiewill

Reputation: 3

Combine commits (not the last, some older ones)

I have some history like that :

First commit -> 2 -> 3 -> some branches and merges -> ...

I have a linear succession of small commits at the beginning (2 -> 3) that I would like to combine together. I have read about git rebase -i, but I dont know how to apply to commits other than the last ones.

Upvotes: 0

Views: 46

Answers (1)

Jonas Fagundes
Jonas Fagundes

Reputation: 1519

Rebase will work to merge 2 and 3 but it will mess with all other developers that have some branches in their repo when they pull your rebased patches.

So this is not recommended if you are sharing your work with others but if it is ok in your context (you are working alone or you can say to every developer to reset their branches to your rebased branch) then just use:

git rebase -i FIRST_COMMIT

and pick all patches but squash 3.

Upvotes: 1

Related Questions