3

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

1
  • “I have used git rebase -i HEAD~10 and squashed the first 10 commits.” Show how you configured the pick list when you did that, what the log looked like after, and what you want to do now.
    – matt
    Commented May 11, 2020 at 20:41

1 Answer 1

4

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.

1
  • 1
    Just what I was about to suggest! Nicely put.
    – matt
    Commented May 11, 2020 at 20:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.