Reputation: 4010
I am facing difficulties in squashing a merged commit, what could be the best way of implementing this, for example below is the screenshot of the 3 commits, I can only manage to squash the 2 (This one 4241338
and this 5b820c3
) but I can't squash the merged commit (bcee6c9
) with the other 2, my goal is to have only one commit on my PR, how best can I do this :
NOTE:
My blocker is on the merged commit
Upvotes: 0
Views: 79
Reputation: 97977
You have fallen into the X/Y problem. Your actual requirement is this:
I want to have only one commit on my PR
You've identified "squashing" as a possible way to achieve this, but run into problems because you needed to merge in other people's work.
A more appropriate solution is a rebase: replay your changes as though they had all happened after everybody else's work. That way no merge will be needed, and you will be free to combine your changes into one.
In short, you would run:
git rebase -i prod
Then in the "todo list" that pops up, change "apply" to "squash" for all except the first commit.
Search online for "git rebase" to find out more; there's no point me repeating all the details here when they're already covered many times elsewhere.
Upvotes: 1