Slide 1

Slide 1 text

Pick Your Git Branching Strategy Lorna Mitchell, October 2015

Slide 2

Slide 2 text

Git Branching

Slide 3

Slide 3 text

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.

Slide 4

Slide 4 text

Commits Aren't "On" Branches

Slide 5

Slide 5 text

Commits Aren't "On" Branches

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Branching Strategy Ingredients List

Slide 8

Slide 8 text

Topic Branches Pattern Starting something new? Use a branch.

Slide 9

Slide 9 text

Topic Branches Pattern Merge from master into feature before merging

Slide 10

Slide 10 text

Topic Branches Pattern Rebase branch onto master before merging

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Hotfix Pattern

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Environment Branches

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Git Branches

Slide 18

Slide 18 text

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