git squash variants

If you just want to squash all commits into one.

1. The simplest way:

https://stackoverflow.com/a/5309051

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:

https://stackoverflow.com/a/5201642

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.
https://stackoverflow.com/a/5189600
I never used it as I really don’t like rebase.

Well, you can do this like that:

Similar Posts

LEAVE A COMMENT