Jesse ansari
Jesse ansari

Reputation: 63

How to divide commits into multiple squashes

I need some help with squashing commits in GitHub.

I have about 30 commits and I want to squash the first 10 commits into one single squashed commit and another 10 commits into another squashed commit. I have used git rebase -i HEAD~10 and squashed the first 10 commits. That works fine. But when I try to squash the next 10 commits, the previously squashed commit also appears in the list. Even though I didn't change the option for squashed commit from "pick" to "squash" that was also included in the resulting squashed commit. As a result I got only one squashed commit. Can anybody please guide me to get two separate squashed commits as per my requirement.

Thanks in advance

Upvotes: 3

Views: 247

Answers (1)

hobbs
hobbs

Reputation: 240659

You need to use pick for the first commit in the new group; squash entries squash onto the previous commit.

And for what it's worth, you can do it in a single rebase. If your pick list looks like

pick a
squash b
squash c
pick d
squash e
pick f
squash g
squash h

You will get one commit with a+b+c squashed, one with d+e, and one with f+g+h.

Upvotes: 4

Related Questions