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

Get The Best From Git

Get The Best From Git

Continuous Lifecycle, London

Lorna Mitchell

May 02, 2016
Tweet

More Decks by Lorna Mitchell

Other Decks in Technology

Transcript

  1. Git Log • git log default format • git log

    --stat show which files were changed and how much • git log --oneline summary format • git log --graph how commits are linked • git log --decorate label branches/tags
  2. Git Diff Useful switches to git diff: • --color-words to

    show adds/deletes inline • --stat to show a list of changed files with an indication of how much changed in each • -w ignore whitespace Just this branch: git diff HEAD...master
  3. Git DiffTool Replace diff with difftool in any command to

    use a different diff viewer. Set your config: git config diff.tool meld
  4. Git Bisect 'when did this stop working ...?' • git

    bisect start to start bisecting • git bisect good|bad committish to set up the range to test
  5. Advanced Git: Bisect Git checks out a series of revisions

    • Test each one • Type git bisect good|bad as appropriate each time • Then git bisect reset to stop bisecting
  6. 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.
  7. Git Flow Comprehensive branching strategy, supported by scripts. • Article:

    http://lrnja.net/1ebawKU • Scripts: https://github.com/nvie/gitflow
  8. Branch Naming • master default branch name • develop often

    used for bleeding edge branch Configure your repo accordingly
  9. 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
  10. Environment Branches Maintain one branch per platform • branch always

    reflects current state of platform • plays well with automated deployment
  11. Tagging for Releases Use annotated tags and attach a message

    git tag -a v2.11 -m "v2.11 with caching" Integrate build tools to react to tag via hook/webhook
  12. Deployables vs Repositories • does each repository only hold one

    deployable item? • does each deployable rely on multiple repositories? • git submodules • dependency management
  13. Sample Branching Strategies • GitHub Flow: http://lrnja.net/1Gr29Jn • Git Flow:

    http://lrnja.net/1ebawKU • Atlassian blog: http://lrnja.net/1BSFQcQ • Docs from GitLab: http://lrnja.net/1AiPxQJ