Skip to content

Merging Pull Requests

Pull requests should be merged with a clean history. If a pull request has a single commit with a well-written commit message, it can be merged within github. Otherwise, the branch should be cleaned up before merging.

Cleaning up history

Merging

  • Merge the feature branch without performing a fast-forward merge. If you rewrote history on the branch, include Closes #1234 in the merge's commit message so the commit will close the open pull request.

Example workflow

Setup

Update your upstream remote config in git to pull in pull request branches. Edit your .git/config:

[remote "upstream"]
   url = git@github.com:upstream/salesforce.git
   fetch = +refs/heads/*:refs/remotes/upstream/*
   fetch = +refs/pull/*/head:refs/remotes/upstream/pull-request/*

Add an ml (merge last branch) alias to your global git config, $HOME/.gitconfig:

[alias]
   co = checkout
   ml = merge --no-ff @{-1}

Merging a pull request

Fetch latest pull requests

git fetch upstream

Check out the pull-request branch

git co pull-request/1234

Squash commits

git rebase -i master

Merge

git co master
git ml

Include Closes #1234 in the merge commit message to automatically close the pull request.

Merge branch 'pull-request/1234' into master

Closes #1234

Push to upstream repo

git push upstream

Update LP

  1. Add a comment to LP that you have merged the pull request, e.g. Merged https://github.com/org/salesforce/pull/1234
  2. Mark the task as Done in LP.