Reputation: 1370
I have the following commits in my branch.
How could I combine commit 3 and 2 but with commit message of commit 2. This is the result I will be expecting
Upvotes: 2
Views: 939
Reputation: 1765
git rebase -i <sha key of first commit>
pick
to squash
at second and third commitUpvotes: 1
Reputation: 37742
you can do this interactively using
git rebase -i HEAD~4
then you will see an editor like
pick <sha-1> commit 1
pick <sha-2> commit 2
pick <sha-3> commit 3
pick <sha-4> commit 4
which you need to change to:
pick <sha-1> commit 1
pick <sha-2> commit 2
fixup <sha-3> commit 3
pick <sha-4> commit 4
save and quit, and that's it.
Upvotes: 7