git squash variants

If you just want to squash all commits into one.

1. The simplest way:

If you have a message like ‘error: failed to push some refs to’, add --force to the last command.

2. If you never merged other changes to <branch-with-changes-you-need> and it’s okay that you’ll be an author of all that changes, you can do the following:

3. The most straightforward way is to
Use git rebase -i and replace «pick» on the second and subsequent commits with «squash» or «fixup», as described in the manual.
I never used it as I really don’t like rebase.

Well, you can do this like that:

Similar Posts