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

Git mastery in twenty minute increments

Git mastery in twenty minute increments

Git topics presented as small, individual, digestible sections.

Videos:
http://www.youtube.com/playlist?list=PLA4B47B9B5F3691E3

Copious slide notes are in the rST source, including setup for each of the demonstrations:
https://github.com/whiteinge/presentations/tree/master/cars_2012-04-27_git

Avatar for Seth House

Seth House

July 24, 2012
Tweet

More Decks by Seth House

Other Decks in Technology

Transcript

  1. Git mastery in twenty minutes increments Seth House <[email protected]> Cars.com

    2012-07-24 Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 1 / 40
  2. Introduction A series of twenty-minute presentations on Git. Figure: Only

    essential information is presented here; for in-depth knowledge check the slide notes for references and read the Pro Git book by Scott Chacon. http://git-scm.com/book/ Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 2 / 40
  3. Objects Outline 1 Objects 2 refnames 3 Merges and mergetool

    4 Remotes 5 Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 3 / 40
  4. Objects Commit objects sha1 hash of: Message Author / committer

    Date Parents (if any) Pointer to the contents (tree) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 4 / 40
  5. Objects Demonstration Create two commits View the raw commit Seth

    House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 5 / 40
  6. Objects Branches A commit knows its parents! Branch names are

    for humans master origin/master Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 6 / 40
  7. Objects Demonstration Create feature branch (off master) Make a commit

    Merge into master Delete the branch Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 7 / 40
  8. Objects Directed acyclic graph (DAG) a053d49 (D) 7858d16 (C) 4938b78

    (B) 710a07c (A) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 8 / 40
  9. Objects Directed acyclic graph (DAG) 3cd72d7 (I) 7d94a91 (H) fb1db9c

    (G) 95b4047 (F) f41f082 (E) 710a07c (A) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 9 / 40
  10. Objects Directed acyclic graph (DAG) 3cd72d7 (I) 7d94a91 (H) fb1db9c

    (G) 95b4047 (F) f41f082 (E) 710a07c (A) a053d49 (D) 7858d16 (C) 4938b78 (B) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 10 / 40
  11. refnames Outline 1 Objects 2 refnames 3 Merges and mergetool

    4 Remotes 5 Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 11 / 40
  12. refnames Git refs “refname” may refer to: sha1 master origin/master

    HEAD HEAD~1 Tags Many, many others; see git-rev-parse(1) for more Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 12 / 40
  13. refnames refs are for humans A ref points to an

    object That’s it Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 13 / 40
  14. refnames Demonstration Delete the ref that points to master Seth

    House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 14 / 40
  15. refnames Objects without refs are garbage collected Unreachable objects older

    than 30 days The reflog counts as a reference reflog entries are pruned after 90 days Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 15 / 40
  16. refnames Demonstration Create a branch Make a new commit Delete

    that branch Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 16 / 40
  17. Merges and mergetool Outline 1 Objects 2 refnames 3 Merges

    and mergetool 4 Remotes 5 Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 17 / 40
  18. Merges and mergetool Fast-forward merges Moves the branch pointer That’s

    it Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 18 / 40
  19. Merges and mergetool Demonstration Make a new branch Make a

    new commit Return to the original branch Merge the new branch Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 19 / 40
  20. Merges and mergetool Merge commits A commit object with two

    parents Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 20 / 40
  21. Merges and mergetool Demonstration Make a new branch Make a

    new commit Return to the original branch Merge the new branch using --no-ff Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 21 / 40
  22. Merges and mergetool Merge conflicts Stages all successful automatic merges

    Surrounds conflicts with conflict markers Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 22 / 40
  23. Merges and mergetool Demonstration Make a branch Make an edit

    Make a new branch Make a conflicting edit Merge the other branch Resolve the conflict Stage the change Commit (use/modify the default message) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 23 / 40
  24. Merges and mergetool mergetool Three-way merge LOCAL BASE REMOTE MERGED

    Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 24 / 40
  25. Merges and mergetool Demonstration View a merge conflict in a

    three-way diff program Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 25 / 40
  26. Remotes Outline 1 Objects 2 refnames 3 Merges and mergetool

    4 Remotes 5 Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 26 / 40
  27. Remotes Remotes Fetching from a remote adds to your local

    DAG “Remote branches” are stored locally You don’t need to define a remote to fetch Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 27 / 40
  28. Remotes Demonstration Fetch a remote branch Compare commits Compare changes

    Merge the remote branch Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 28 / 40
  29. Remotes Remote tracking At-a-glance comparison Syntactic sugar Track any ref

    (not just “remote branches”) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 29 / 40
  30. Rebase Outline 1 Objects 2 refnames 3 Merges and mergetool

    4 Remotes 5 Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 30 / 40
  31. Rebase Rebase on incoming changesets git rebase <upstream> <branch> git

    fetch && git rebase git pull --rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 31 / 40
  32. Rebase Demonstration Simulate a local and upstream branch that have

    diverged Rebase Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 32 / 40
  33. Rebase Rebase in detail git rebase <upstream> <branch> Commits shown

    by git log <upstream>..HEAD Current branch is reset git reset --hard <upstream> ORIG_HEAD is set to branch point before the reset Commits reapplied, one by one, in order Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 33 / 40
  34. Rebase Demonstration Given two branches with divergent history Replay the

    second branch on top of the first Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 34 / 40
  35. Rebase Rebase a subset (transplant) Transplant a topic branch based

    on one branch to another Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 35 / 40
  36. Rebase Demonstration Branch featureA based off master Branch featureB based

    off featureA Realize featureB is unrelated and should be based off master instead Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 36 / 40
  37. Rebase Demonstration 4563b4d (HEAD, featureB) cd6e0c6 bf2abbf 47c9e6b 187fa1a (featureA)

    d278922 40c6165 9db2b8c (master) Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 37 / 40
  38. Rebase Demonstration 23bb8f0 (HEAD, featureB) 59dfaa8 9db2b8c (master) d278922 *4563b4d

    *cd6e0c6 bf2abbf 47c9e6b 187fa1a (featureA) 40c6165 Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 38 / 40
  39. Rebase Interactive git rebase -i HEAD~5 Reshuffle, fixup, squash commits

    Seth House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 39 / 40
  40. Rebase Demonstration Make seven commits Squash, reword, and fixup Seth

    House <[email protected]> (Cars.com) Git mastery in twenty minutes increments 2012-07-24 40 / 40