So Help Me God, You Will Understand Git's Model, Even If It Kills Me

So Help Me God, You Will Understand Git's Model, Even If It Kills Me

1945ab4cdb87eaf5a5c906fa884c29f1?s=128

Scott Robinson

April 25, 2012
Tweet

Transcript

  1. Go drink. Presentation starts at 6pm.

  2. 1 2 3 4 6 7 8 9 11 15

    16 10 12 14 5 13 Trunk Branches Merges Tags Discontinued development branch
  3. Everyone Has A Fork • Offline • No server necessary

    • Frequent branching and merging
  4. None
  5. So Help Me God, You Will Understand Git’s Model Even

    If It Kills Me
  6. SHA1 $ echo 'HELLO TWU' | shasum 7068de75a45caca38a6d772d4b0f371bda003256 -

  7. Git Object Model •K: SHA(data) •V: data

  8. Objects •Type •Size •Content

  9. Blobs Trees Commits Refs Tags

  10. Blobs $ git cat-file -p 1377554ebea6f98a2c748183bc5a96852af12ac2 *.swp

  11. Trees $ git ls-tree eebc19d60284277eba86620ec828d73d0cdf822a 100644 blob 1377554ebea6f98a2c748183bc5a96852af12ac2 .gitignore 100644

    blob ac1bfdc65a699792310498fc0ba003e61eddf1d0 bad.lua 100644 blob b2f5ce962808f4edd04336eb803b6445b843e052 boom.lua 100644 blob 6b1c0b8946e40ff393f73d80a885fdd39fba93dd bullet.lua 100644 blob 268a04ca259b566c7340d8ba8dab8ce0590e8352 main.lua 100644 blob 67638336f18030013b0bcc7533987a6ba892ba46 rail.lua 040000 tree 415ee50b6cf27815df2750de33b0eac1df8ad814 resources 100644 blob c1a79a49a98c0b3868e33270465121cf40dc622e ship.lua 100644 blob d77c7f1d5fecfc6c998e2eec628495075ba27ec1 wave.lua
  12. Commit •Tree •Parent(s) •Author and Committer •Message

  13. Commit $ git cat-file -p eea6bd6db666365b33496b9fc4c2d55c7af8fdcd tree eebc19d60284277eba86620ec828d73d0cdf822a parent bfe1204bb4d8eaa00b7a20c47e6e421e9be25322

    author Sam Gibson <sam@ifdown.net> 1327417487 +0530 committer Sam Gibson <sam@ifdown.net> 1327417487 +0530 Bounds -> Box
  14. Tags •Annotated •Lightweight

  15. Annotated Tag •Object SHA1 •Type •Tagger •Message

  16. Refs (lightweight tags) •Branches (local and remote) •Heads •Tags

  17. INCOMING COPYRIGHT VIOLATION

  18. In Summary http://book.git-scm.com/1_the_git_object_model.html

  19. Let’s Play A Game “What Happens?”

  20. What Happens? $ git init Initialized empty Git repository in

    /.git/
  21. Yes, that was a warm up $ find ./.git .

    ./.git ./.git/config ./.git/description ./.git/HEAD ./.git/hooks ... ./.git/info/exclude ./.git/objects/info ./.git/objects/pack ./.git/refs/heads ./.git/refs/tags
  22. What Happens? $ touch xyzzy $ git add xyzzy $

    git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: xyzzy #
  23. The Index •Cache •Staging •Whitelist?!

  24. You Delete A File And Then Commit It? $ rm

    xyzzy $ git commit -m 'What happens?'
  25. You Can’t Explain That! $ ls $ git status #

    On branch master # Changes not staged for commit: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: xyzzy # no changes added to commit (use "git add" and/or "git commit -a") $ git checkout -- xyzzy $ ls xyzzy
  26. Reflogs $ git reflog add17aa HEAD@{0}: commit: NO a1b7f8d HEAD@{1}:

    commit (initial): What happens?
  27. Practical Examples whereupon mayhap we conversate

  28. Fetch Imports remote refs and their associated objects

  29. 3-Way Merge • "your" commit • "their" commit • their

    most recent ancestor
  30. Rebase • "your" commit • "their" base commit • their

    most recent ancestor • Replays each of “your” differences upon “their” base
  31. Stash Working Directory Index HEAD

  32. fin

  33. Git Community Book http://book.git-scm.com