-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Merging a Pull Request
-
Please read on how to do an interactive rebase:
git rebase -i
Some good references:https://help.github.com/articles/about-git-rebase/ https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase-i
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
.
First lets say you have a PR: https://github.com/angular-ui/bootstrap/pull/1234
- 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
- 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.
- 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
.
- 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 -
- 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
- Reset your local master to upstream's master.
git fetch upstream master
git checkout -B master upstream/master
- Rebase your pull request branch on top of your updated local master.
git checkout pull/1234
git rebase master
- Continue on step 4 in the previous section.