Skip to content

Instantly share code, notes, and snippets.

@parasquid
Last active October 26, 2017 15:03
Show Gist options
  • Save parasquid/3746535ec11e013e6e54da750caa1d3b to your computer and use it in GitHub Desktop.
Save parasquid/3746535ec11e013e6e54da750caa1d3b to your computer and use it in GitHub Desktop.
Branching workflow

When hotfixes need to be applied and deployed to production:

  • Make sure that the hotfix branch is branched off from the production branch and not the development branch.
  • Send a pull request for the production branch. The production branch isn't protected for merges like the development branch, so you can merge them yourself (useful in cases of emergency and no one us there to approve your PR) but if possible, as someone to merge the code for you.
  • Send a pull request to the development branch so the pull request exists in both branches.
  • In case the PR does not merge cleanly with development please branch off from the hotfix branch, fix the merge conflicts, and then merge that into development

Note that the production branch doesn't need to have its own canonical history; only development has that property. This means that in case the production branch becomes fully out of sync with development it is not forbidden to just delete "bad" production branch and just recreate it from development.

Some illustrations:

Branch the hotfix off of production

    +<<<<<<<<<<<<<<<+<<<<hotfix
    |               |      |
    |               |     /
    |               |    /
    |               |   /
    |               |  /
    |               | /
    |               |/
    |               +
development    production
    |               |
    |              /
    |             /
    |            /
    |           /
    |          /
    |         /
    |        /
    |       /
    |      /
    |     /
    |    /
    |   /
    |  /
    | /
    |/
    +

If the hotfix branch doesn't merge cleanly:

    +<<<<<<<<<<<<<<<<<<<<<<fix-merge-conflict
    |                              |
    |                             /
    |                            /
    |                           /
    |                          /
    |                         /
    |                        /
    |                       /
    |                      |
    |               +<<<<hotfix
    |               |      |
    |               |     /
    |               |    /
    |               |   /
    |               |  /
    |               | /
    |               |/
    |               +
development    production
    |               |
    |              /
    |             /
    |            /
    |           /
    |          /
    |         /
    |        /
    |       /
    |      /
    |     /
    |    /
    |   /
    |  /
    | /
    |/
    +

Note: DO NOT commit to the production branch directly! It might be the fastest way to get things merged, but it WILL cause auditing problems in the future. Be cool, calm, and collected about this, and don't rush it (it's a hotfix, so we want to avoid a hotfix for a botched hotfix).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment