Skip to content

Manually merging pull requests

sbrannen edited this page Aug 6, 2012 · 20 revisions

This page serves as a simple "how to" for Spring committers when manually merging pull requests from contributors.

Placeholders

Many of the git commands listed below contain placeholders as defined below.

  • <ACCOUNT>: GitHub account for the author of the pull request
  • <BRANCH>: branch in pull request author's account (e.g., SPR-####)
  • <PULL_REQUEST_NUMBER>: spring-framework pull request number

Example

To determine the values for these placeholders, let's take a look at pull request #113 as an example. From the pull request page you should be able to find an example git command for pulling the request into your local working directory -- for example, git pull git:/aclement/spring-framework.git SPR-9613.

Performing the Merge

Set up remote, fetch branch, and rebase

git co master
git remote add <ACCOUNT> https:/<ACCOUNT>/spring-framework.git
git fetch <ACCOUNT>
git co --track <ACCOUNT>/<BRANCH> -b <BRANCH>
git rebase master

Modify working directory

  • polish, format, refactor, document, update changelog, etc.
  • once changes are finalized and committed to the branch, squash commits into a single commit. For example: git rebase --interactive --autosquash

Merge into master and push

git co master
git merge --no-ff --log -m "Merge pull request #<PULL_REQUEST_NUMBER> from <ACCOUNT>/<BRANCH>" <BRANCH>
git push springsource master:master

Cleaning Up

Update remote pull request branch to rebased/modified version (optional)

This is only possible if you have write permissions for the remote repository -- for example, if you are merging your own pull request.

git push --force <ACCOUNT> <BRANCH>

Delete remote pull request branch (optional)

This is only possible if you have write permissions for the remote repository -- for example, if you are merging your own pull request.

git push <ACCOUNT> :<BRANCH>

Delete local branch (optional)

git branch -D <BRANCH>

Delete local remote entry (optional)

git remote rm <ACCOUNT>