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

Git's Golden Rules (for Teams)

Git's Golden Rules (for Teams)

Let's face it, everyone can punch some commands into Git and make things go splat. That's the easy part. Understanding *why* and *when* to apply various commands is the hard part of learning to be an effective Git team player. This session will briefly cover the four most important factors that will determine your project's success in working with Git:

- Access control -- who and how people can update a shared repository
- Common branching patterns -- what they are, and how to choose one
- Maintenance strategies -- how to keep your local repository up-to-date
- Repository architecture -- files to include, and omit

Tweet

More Decks by Emma Jane Hogbin Westby

Other Decks in Technology

Transcript

  1. TODAY GIT'S GOLDEN RULES ▸ Talk to your teammates. ▸

    Separate your ideas. ▸ Be consistent. ▸ Include only what you need.
  2. GOLDEN RULE TALK TO YOUR TEAMMATES. ▸ Map access, then

    map commands. ▸ Use branch locking or forks to control access.
  3. USE A CONVENTION (OR INVENT YOUR OWN … ENDING IN

    “FLOW”) POPULAR BRANCHING CONVENTIONS ▸ State / Environment Branching (GitLab Flow) ▸ Branch-Per-Feature (GitHub Flow) ▸ Scheduled Release (GitFlow)
  4. GOLDEN RULE SEPARATE YOUR IDEAS. ▸ Every commit and each

    branch should hold
 a coherent unit of work.
  5. pull fetch + merge pull --rebase=preserve fetch + rebase merge

    --no-ff forces a merge commit object
 (“true merge”) merge --ff-only fast forward (graph looks like rebase) merge --squash compress commits to one; then merge rebase forward-port local commits cherry-pick merge individual commits WHY THE FUSS? BECAUSE TIMTOWTDI
  6. GOLDEN RULE BE CONSISTENT. ▸ Keep your history legible by

    having the team use a single strategy to update branches.
  7. IF YOU MUST INCLUDE EXTERNAL WORK ▸ Keep your "core"

    clean and track upstream work with named branches. ▸ Nest repositories without tracking by using subtrees (clone inside a clone). ▸ Git can track external repositories with submodules.
 There be dragons.
  8. USE SHALLOW CLONES FOR FASTER DEPLOYMENTS $ GIT CLONE --DEPTH

    [DEPTH] [REMOTE-URL] $ GIT CLONE [URL] --BRANCH [BRANCH_NAME]
 --SINGLE-BRANCH [FOLDER]
  9. GOLDEN RULE INCLUDE ONLY WHAT YOU NEED. ▸ Outsource your

    dependency management. ▸ Break your repository into smaller service repositories when it's time. ▸ Binary files grow when versioned. ▸ Use shallow clones for faster deployments.
  10. TODAY GIT'S GOLDEN RULES ▸ Talk to your teammates. ▸

    Separate your ideas. ▸ Be consistent. ▸ Include only what you need.
  11. RESOURCES BIG REPOSITORIES ▸ How to Handle Big Repositories with

    Git
 https://www.atlassian.com/git/articles/how-to-handle-big- repositories-with-git/ ▸ How do you handle your microservices
 https://news.ycombinator.com/item?id=9705098 ▸ Organizing Microservices in a Single Repository
 http://blog.plataformatec.com.br/2015/01/organizing- microservices-in-a-single-git-repository/
  12. RESOURCES DEPENDENCY MANAGEMENT ▸ How do you handle external dependencies?


    http://programmers.stackexchange.com/questions/110093/how- would-one-handle-external-dependencies-in-an-open-source-project ▸ Paket for .NET and Mono
 http://fsprojects.github.io/Paket/ ▸ Composer for PHP
 https://getcomposer.org/doc/00-intro.md ▸ Mastering Submodules
 https://medium.com/@porteneuve/mastering-git- submodules-34c65e940407
  13. RESOURCES TRACKING (LARGE) BINARY FILES ▸ Do not version binaries

    in the repository; reference them from another location. ▸ git-annex - https://git-annex.branchable.com/ ▸ git-bigfiles - http://caca.zoy.org/wiki/git-bigfiles ▸ GLFS - https://git-lfs.github.com ** start here ▸ http://blogs.atlassian.com/2014/05/handle-big- repositories-git/