Can we use rebase to squash multiple commits into one single commit on the same branch?
Taking an example, i have created two topic branches - issueA_1 and issueA_2 from master. I make a couple of commits in both branches, as can be seen in the diagram(i am using commit names here instead of commit hashes for brevity) :
--> (issueA_1) - commitX1 / (master)-- \ --> (issueA_2) | commitY1 | commitY2 Then i do :
git checkout issueA_2 git rebase -i issueA_1 I change the rebase file to :
pick commitY1 fixup commitY2 After this rebase, the commit history looks like this :
--> (issueA_1) - commitX1 / (master)-- \ --> (issueA_2) | commitX1 | commitY1 | commitY2 I don't need the branch issueA_1 anymore, so i do :
git branch -D issueA_1 The commit history of issueA_2 isn't pretty enough to be merged into master yet. I want commitX1, commitY1 and commitY2 of this branch to be squashed into 1 single commit before i merge into master. Is this possible?