If possible, interactively rebase your feature branch against master
before merging, and condense your work-in-progress commits to clean, single-purpose commits.
Prereq: install git-up
git up
git checkout <feature-branch>
git rebase -i master
If rebasing master presents conflicts, you should merge the feature branch with merge --squash
instead:
git checkout <feature-branch>
git checkout -b <feature-branch>-backup # Store a backup of your feature branch
git checkout master
git merge —-squash <feature-branch>
git commit
git branch -D <feature-branch>
git checkout -b <feature-branch> # Create the same branch again, with your single commit
git push -f origin <feature-branch>
You should now have a single merged commit on your PR branch, <feature-branch>
. After things look good, you can delete <feature-branch>-backup
.