Skip to content

Instantly share code, notes, and snippets.

@neilrenicker
Last active May 6, 2016 05:00
Show Gist options
  • Save neilrenicker/f61dda7a74ec66df115b to your computer and use it in GitHub Desktop.
Save neilrenicker/f61dda7a74ec66df115b to your computer and use it in GitHub Desktop.

Merging Pull Requests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment