Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pick Your Git Branching Strategy

Pick Your Git Branching Strategy

When working out the best strategy for your team, there are a few key questions that will influence your decision. This session runs through and gives advice on how to put together a workflow that works for your particular scenario

Lorna Mitchell

October 29, 2015
Tweet

More Decks by Lorna Mitchell

Other Decks in Technology

Transcript

  1. Pick Your Git
    Branching Strategy
    Lorna Mitchell, October 2015

    View Slide

  2. Git Branching

    View Slide

  3. A Branch is a Label
    Take a look in .git/refs/heads/
    • A branch is a pointer to a commit.
    • You commit on a branch, the commit is
    created and the pointer updated.

    View Slide

  4. Commits Aren't "On" Branches

    View Slide

  5. Commits Aren't "On" Branches

    View Slide

  6. Sample Branching Strategies
    • Git Flow: http://lrnja.net/1ebawKU
    • GitHub Flow: http://lrnja.net/1Gr29Jn
    • Atlassian blog: http://lrnja.net/1BSFQcQ
    • Docs from GitLab: http://lrnja.net/1AiPxQJ
    Some common elements between these

    View Slide

  7. Branching Strategy
    Ingredients List

    View Slide

  8. Topic Branches Pattern
    Starting something new? Use a branch.

    View Slide

  9. Topic Branches Pattern
    Merge from master into feature before merging

    View Slide

  10. Topic Branches Pattern
    Rebase branch onto master before merging

    View Slide

  11. Branch Naming
    • master default branch name
    • develop often used for bleeding edge branch
    Configure your repo accordingly

    View Slide

  12. Hotfix Pattern
    Branch off, commit once, merge with --no-ff
    • makes it very clear what happened
    • easily merge the branch back upstream if
    needed
    • makes it possible to cleanly undo without
    losing anything

    View Slide

  13. Hotfix Pattern

    View Slide

  14. Environment Branches
    Maintain one branch per platform
    • branch always reflects current state of
    platform
    • plays well with automated deployment

    View Slide

  15. Environment Branches

    View Slide

  16. Tagging for Releases
    Git has two types of tags:
    • simple tags are just a label, like a branch that
    doesn't advance
    • annotated tags are an object, they can
    contain messages
    git tag -a v2.11 -m "v2.11 with caching"
    Then push the tag

    View Slide

  17. Git Branches

    View Slide

  18. Resources
    • These slides: http://lornajane.net/resources
    • My git book: http://gitworkbook.com/

    View Slide