How can I combine 1st commit with 4th commit in git using 'git rebase'. From what I read here http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html, the 'squash' command in 'git rebase' only meld into previous commit.
in git, I have
$ git log
commit 9a30d13
commit 4a6729e
commit 4a6729e
commit 4a6729e
commit a610898
Basically, I want changes from 9a30d13 to combine with changes in a610898, so that the new history is
$ git log
commit 4a6729e
commit 4a6729e
commit 4a6729e
commit a610898 + 9a30d13
I have not pushed anything.
Thank you.
When you do an interactive rebase as described at your link, you can reorder the commits, too. Once you change the order, you can squash 9a30d13 into a610898.
When the interactive rebase comes up, it will look something like this (with the oldest commits on top):
pick a610898 Message A
pick 4a6729e Message B
pick 4a6729e Message C
pick 4a6729e Message D
pick 9a30d13 Message E
You then reorder them:
pick a610898 Message A
pick 9a30d13 Message E
pick 4a6729e Message B
pick 4a6729e Message C
pick 4a6729e Message D
And change 9a30d13 to squash rather than pick:
pick a610898 Message A
squash 9a30d13 Message E
pick 4a6729e Message B
pick 4a6729e Message C
pick 4a6729e Message D
Save & exit, and you're done. You'll get a chance to enter a new commit message for your new a610898 + 9a30d13 commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With