From 5b3e9724883f0ed4e8ad0bc2d659a0521c733b86 Mon Sep 17 00:00:00 2001 From: Yusra AlSayyad Date: Fri, 28 Sep 2018 20:13:27 -0400 Subject: [PATCH] Add instructions to rebase and push branch before merging --- work/flow.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/work/flow.rst b/work/flow.rst index a85c8e77..e4c524a9 100644 --- a/work/flow.rst +++ b/work/flow.rst @@ -474,11 +474,22 @@ We **always use non-fast forward merges** so that the merge point is marked in G .. code-block:: bash + # Prepare to merge + git checkout master + git pull # Sanity check; if master is up-to-date, skip ahead to "Merge" below + git checkout tickets/DM-NNNN + git rebase master + git push --force # so that the commits on the remote branch match the commits merged* + # Merge git checkout master - git pull # Sanity check; rebase ticket if master was updated. git merge --no-ff tickets/DM-NNNN git push +We force push the rebased branch for three reasons: +(1) In many repos, branch protection requires that Travis was run on any commits before they can be pushed onto master +(2) The policy is to delete branches that have been merged. This is only possible if the exact commit has been merged. +(3) For convenience, Github will automatically close pull requests if the corresponding branch has been merged to master. + **GitHub pull request pages also offer a 'big green button' for merging a branch to master**. We discourage you from using this button since there isn't a convenient way of knowing that the merged development history graph will be linear from GitHub's interface. Rebasing the ticket branch against ``master`` and doing the non-fast forward merging on the command line is the safest workflow.