git rebase -i <hash-of-the-last-commit-before-commit1>
The editor will open with a list, for example:
pick commit1 pick commit2 pick commitN
Edit the lines this way:
reword commit1 fixup commit2 fixup commitN
Save and exit the editor.
The editor will open again - just enter the name of your final commit.
Now you can direct your single commit to the server.
source share