Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Merging a Pull Request

Chris Chua edited this page Apr 6, 2015 · 1 revision

Before you proceed

Setup

These instructions assume that your setup has a remote called upstream-merge pointing to the angular-ui/bootstrap repository (with push priviledges) and a read-only upstream remote from retrieving upstream changes.

This is the recommended setup. However, the instructions will also work if your setup only has one upstream remote. Just replace instances of upstream-merge with upstream.

Steps to merge a PR

First lets say you have a PR: https://github.com/angular-ui/bootstrap/pull/1234

  1. First, checkout master, make sure it's up-to-date, and create a branch called pull/1234:
git checkout master
git pull upstream master
git checkout -b pull/1234
  1. Fetch and merge (pull) the PR's commits and merge locally.
git pull --no-edit upstream pull/1234/head

Note the --no-edit option is used to skip editing the merge commit message. The reason for this is that there'll be a rebase later to edit the messages anyway and this commit will be discarded during rebase.

  1. Rebase and edit the commits as desired.
git rebase -i master

There are a few things to note here. Mark issues and pull requests that are fixed or closed with Fixes #<issue> or Closes #<issue>. A typical commit message looks like:

feat(modal): add option to disable animations

Note: Move backdropClass logic into compile function because otherwise
modifying classes in the compile function is broken when using an interpolated
class attribute.

Fixes #1007
Closes #2725

The format of the commit message, along with mentioning all the issues closed/fixed is important for the changelog script used to update CHANGELOG.md .

  1. Checkout master and merge your newly rebased branch. Note that this shouldn't create a merge commit as it's fast-forwarded.
git checkout master
git merge pull/1234 # alternatively: git merge -
  1. Finally, push to upstream. If it's successful, you're done! Please note never force push to master. It'll break other user's clones of the repository as well as TravisCI. If by this step, the push is rejected, you can either repeat the steps above, or follow the steps below in the next section.
git push upstream-merge master

If your push was rejected

  1. Reset your local master to upstream's master.
git fetch upstream master
git checkout -B master upstream/master
  1. Rebase your pull request branch on top of your updated local master.
git checkout pull/1234
git rebase master
  1. Continue on step 4 in the previous section.