I have try to use git rebase -i HEAD~3
to squash all the commit. But git throw below error, for the commit HEAD~3
is not exist.
fatal: invalid upstream 'HEAD~3'
$ git log --oneline
7cabc02 (HEAD -> master) fix bug
26a9c03 fix bug
59fe21b record video process
So, how can I squash all the commit to one.
The way to squash those three commits, including the first one, is to run the following command:
Please note that the
--root
option was introduced in git version 1.7.12.Running this command will open the interactive dialog to perform the rebase and that dialog will include your first commit. In that dialog, leave the first commit as
pick
and set the other two tosquash
. Save and quit your editor to perform the operation.