How to Successfully Use Branching and Development Workflow Strategies

23
Git Workflows How to Successfully Use Branching & Development Workflow Strategies Nik Gregory Principal Engineer Twitter: @nikgregory

Transcript of How to Successfully Use Branching and Development Workflow Strategies

Page 1: How to Successfully Use Branching and Development Workflow Strategies

Git WorkflowsHow to Successfully Use Branching & Development Workflow Strategies

Nik GregoryPrincipal EngineerTwitter: @nikgregory

Page 2: How to Successfully Use Branching and Development Workflow Strategies

Syllabus→ Popular git branching and workflow methods→ Dive into git branch-per-feature→ Pitfalls of git branch-per-feature and avoiding them→ Questions

Page 3: How to Successfully Use Branching and Development Workflow Strategies

About Me→ Acquia Engineer since 2009→ Initial QA/Test hire at Acquia→ Worked with Acquia hosting, Site Factory…

Page 4: How to Successfully Use Branching and Development Workflow Strategies

Caveat Inspectoris→ I am not a git ninja

▪ I know enough about git to get the job done and google the rest

→ Git development workflows == emacs vs vi▪ Pick what works for you and your team.

Page 5: How to Successfully Use Branching and Development Workflow Strategies

Long Running Branches

▪ Master is dev▪ Releases are a branch▪ Hotfixes get merged into master▪ Not very different than CVS or SVN (release branches

are easier to handle)

Page 6: How to Successfully Use Branching and Development Workflow Strategies

Git fork→ Maintainer controls merges into official repo→ Often master is known good→ Forkers pull from master as master moves→ Often used in Open Source development→ Useful in restricting access to the official repo

Page 7: How to Successfully Use Branching and Development Workflow Strategies

Branch per feature→ Modified version of git-flow→ Master is known good production code→ Each story gets a new branch→ Mitigates risk when pulling in lots of stories→ QA and RC branches are built regularly

▪ Master + feature branches→ Integration is used to catch merge conflicts→ Shared rereres are your friend

Page 8: How to Successfully Use Branching and Development Workflow Strategies

Standing on the Shoulders of Giants→ Based on the work of Adam Dymitruk→ Refined by Katherine Bailey and myself

Page 9: How to Successfully Use Branching and Development Workflow Strategies

Git Branch-per-feature

Page 10: How to Successfully Use Branching and Development Workflow Strategies

Details→ Create a branch from master for your stories

▪ git checkout master && git pull origin master && git checkout –b JIRA-1▪ git checkout master && git pull origin master && git checkout –b JIRA-2▪ …

→ Code like no one is watching, commit, push to origin→ Merge your work into the integration/QA/RC branch

▪ git checkout <(integration|QA|RC)branch> && git pull …▪ git pull –no-rebase –no-ff [--no-edit] origin JIRA-1▪ …

Page 11: How to Successfully Use Branching and Development Workflow Strategies

Merge Conflicts→ Use your integration branch as the conflict detector→ Use git rerere to record your conflict resolutions.→ Share your rereres with the git-bpf gem→ Rebuild your QA/RC branches as needed→ Recreate Integration from master as master moves

Page 12: How to Successfully Use Branching and Development Workflow Strategies

Quick and dirty examples→ Install (gem install git_bpf) and initialize git-bpf

Page 13: How to Successfully Use Branching and Development Workflow Strategies

Cont…→ Build your branch

Page 14: How to Successfully Use Branching and Development Workflow Strategies

Record resolutionsFix your stuff git-bpf will share your resolution

Page 15: How to Successfully Use Branching and Development Workflow Strategies

Rebuild your branch

Page 16: How to Successfully Use Branching and Development Workflow Strategies

Add more work and rebuild

Page 17: How to Successfully Use Branching and Development Workflow Strategies

Exclude branches

Page 18: How to Successfully Use Branching and Development Workflow Strategies

Advantages→ Usually trivial to pull out stories (see the Q&D earlier)→ Story branches always start from the tip of master→ Rebase is no longer scary→ Rebuild your QA/RC branches as needed

Page 19: How to Successfully Use Branching and Development Workflow Strategies

Advantages, even more→ You do not need to release broken code!→ Run through tests and things go sideways

▪ Rebuild a new RC▪ Validate

→ No panic feature flags!→ Master is still known good best code.→ To reiterate: the most important advantage is being able to

NOT release stories

Page 20: How to Successfully Use Branching and Development Workflow Strategies

Pitfalls→ Overhead to deal with many branches and merging→ Common code changes are needed among several branches

▪ Are your stories nice independent releasable units?▪ Can you use a parent /child branch to share?

→ Incorrect Resolution is recorded.▪ Minor brain surgery on .git/rr-cache

→ Pulling out branches sometimes requires new rereres▪ Are you all working in the same section of code?

→ If master moves rebase your branches to HEAD of master

Page 21: How to Successfully Use Branching and Development Workflow Strategies

Questions?

Page 22: How to Successfully Use Branching and Development Workflow Strategies

Resources→ Kat Bailey’s writeup: https://dev.acquia.com/blog/pragmatic-guide-branch-

feature-git-branching-strategy→ Our jumping off point http://dymitruk.com/blog/2012/02/05/branch-per-

feature/→ git-bpf gem → Git-flow http://nvie.com/posts/a-successful-git-branching-model/→ Git command visualizations http://onlywei.github.io/explain-git-with-d3

Page 23: How to Successfully Use Branching and Development Workflow Strategies

Thank You