Suppose you did 3 commits on a feature branch called feature
:
ae1a4a5 Foo
a5827db Bar
62d4c80 Baz
Make sure develop branch is up to date:
git checkout develop
git pull --rebase origin develop
Carry out the interactive rebase:
git checkout feature
git rebase -i develop
Now at this point you should see something like the following in your terminal:
pick ae1a4a5 Foo
pick a5827db Bar
pick 62d4c80 Baz
You can now modify your git history. Squash all the commits down into a single commit:
reword ae1a4a5 Foo
fixup a5827db Bar
fixup 62d4c80 Baz
Note: don't use squash as that automatically uses the existing commit message from the commit we're squashing other commits into. Use reword and fixup instead.
Rewrite your feature branch on origin:
git push --force-with-lease origin feature