Correcting pull requests with merge commits

If a pull request contains merge commits (any commit containing "Merge branch 'XXX'..."), please reject it instructing the author to correct their branch and resubmit. The following outlines the steps to take to undo a merge commit.

Here's a graph showing a merge commit in branch "A" (commit 758235f) joining it to branch "B", with more work done after the merge. (show graph with "git log --graph --oneline --all"):

*   b2f597e further work based on merge of B
|
*   758235f Merge branch 'B' into A
|\  
| * 9db0c1a work on branch B
* | 7375fa3 work on branch A
|/  
* b64d479 Ancestor work on A

To correct this, rebase back on to the commit right before the merge was made: "git rebase -i 7375fa3". The following will open in your configured text editor:

pick 9db0c1a work on branch B
pick b2f597e further work based on merge of B

# Rebase 7375fa3..b2f597e onto 7375fa3
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#

Remove all commits from branch B by deleting those lines (just 9db0c1a in this case). Leave the rest as "pick". Exit the editor. You may run into conflicts. Correct them as you normally would and "git rebase --continue". Once the rebase is complete the branch graph should look like the following.

* 536fd47 further work based on merge of B
* 7375fa3 work on branch A
| * 02881af another one
| * 9db0c1a another
|/  
* b64d479 Ancestor work on A

At this point your branch is ready to be rebased onto the work done in branch "B". This is done by executing "git rebase B". After correcting any conflicts and continuing the rebase "git rebase --continue", the "A" branch should now have a very flat structure with both the work done on B as well as the subsequent work on A. There should be no merge commits:

* 48cd9af further work based on merge of B
* 2495a40 work on branch A
* 9db0c1a work on branch B
* b64d479 Ancestor work on A

At the point the work can be pushed back to GitHub and the pull request should update automatically.