Rebase to squash pushed commits into single commit before merge.
- Print a pretty log to deteremine number of commits
git log --pretty=format:"%h %s" HEAD~11..HEAD
- Rebase to squash commits together in editor
git rebase -i HEAD~11
change pick
to f
when you want to merge changes to top commit and discard the message of fixup commit;
choose squash
for commits where you want to combine the messages,
and to reword
for the topmost one to reword the final commit. If you don't want to rewrite topmost commit message, keep it as is.
- Different steps based on master state
a) If master has changes you want to integrate before force pushing, rebase with master first
git rebase -i origin/master
Would be good if there was a local git graph to check that your changes are moved on top of master now.
Then push softly to your branch on remote.
git push origin your-branch-name --force-with-lease
b) Otherwise, if you don't have any updates on master to rebase, you can push to branch with + force
git push origin +yourBranchName
- Now create a PR for review and when done, merge to master.