User_Targaryen
User_Targaryen

Reputation: 4225

Git .. squash specific commits

This is what I get when I do a git rebase -i HEAD^5.

pick 0a81405 Bug Fix 1
pick 91be655 Bug Fix 2
pick 1200fc7 Some other user's commit
pick 1211fb7 Bug Fix 3
pick ba77fdf Bug Fix 4

I want to squash the Bug Fix commits into one commit without touching the Some other user's commit

Is it possible to achieve this? If yes, how? If no, how can I get around this problem?

Upvotes: 3

Views: 2482

Answers (1)

Mateusz
Mateusz

Reputation: 2317

You can do it like that, just reorder lines:

pick 0a81405 Bug Fix 1
fixup 91be655 Bug Fix 2
fixup 1211fb7 Bug Fix 3
fixup ba77fdf Bug Fix 4
pick 1200fc7 Some other user's commit

Might be problematic if you have some code in fixes that depends on some user's commit and I hope it is your local repository. Otherwise you will have problem with pushing your changes.

So maybe better if you just leave it as it is, and do your fixes in feature branch first and then publish.

Upvotes: 6

Related Questions