http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
I ran
git rebase --interactive HEAD~2
In the resulting editor, I change pick to squash and then save-quit, but the rebase fails with the error
Cannot squash without a previous commit
Now that my work tree has reached this state, I’m having trouble recovering. The command git rebase --interactive HEAD~2 fails with
Interactive rebase already started
and git rebase --continue fails with
Cannot squash without a previous commit
Get back to where you started with
$ git rebase --abort
Say your history is
$ git log --pretty=oneline
a931ac7c808e2471b22b5bd20f0cad046b1c5d0d c
b76d157d507e819d7511132bdb5a80dd421d854f b
df239176e1a2ffac927d8b496ea00d5488481db5 a
That is, a was the first commit, then b, and finally c.
Running git rebase --interactive HEAD~2 gives you an editor with
pick b76d157 b
pick a931ac7 c
# Rebase df23917..a931ac7 onto df23917
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit s log message
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Changing b s pick to squash will result in the error you saw, but if instead you squash c into b by changing the text to
pick b76d157 b
s a931ac7 c
and save-quitting your editor, you ll get another editor whose contents are
# This is a combination of 2 commits.
# The first commit s message is:
b
# This is the 2nd commit message:
c
When you save and quit, the contents of the edited file become commit message of the new combined commit:
$ git log --pretty=oneline
18fd73d3ce748f2a58d1b566c03dd9dafe0b6b4f b and c
df239176e1a2ffac927d8b496ea00d5488481db5 a
http://stackoverflow.com/questions/2563632/how-can-i-merge-two-commits-into-one