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

Springest devlunch: Git

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Springest devlunch: Git

Small in-company presentation about the internals of git and a simple use case that uses this knowledge.

Avatar for Maarten Hoogendoorn

Maarten Hoogendoorn

March 01, 2013

Other Decks in Programming

Transcript

  1. Blob This is a blob (Binary Large OBject) It has

    a unique SHA (Secure Hash Algorithm) 5/16
  2. Blob This is a blob (Binary Large OBject) It has

    a unique SHA (Secure Hash Algorithm) same blob ⇒ same SHA 5/16
  3. Blob This is a blob (Binary Large OBject) It has

    a unique SHA (Secure Hash Algorithm) same blob ⇒ same SHA How does it look like? $ git hash-object Makefile 8384c7c4b3e1460c92f02c78a89c4467ba3c17e4 5/16
  4. File system trees $ tree . |-- presentation.pdf |-- presentation.tex

    |-- figures | |-- blob.pdf | \-- springest.pdf |-- Makefile \-- settings.tex 6/16
  5. File system trees $ tree . |-- presentation.pdf |-- presentation.tex

    |-- figures | |-- blob.pdf | \-- springest.pdf |-- Makefile \-- settings.tex Files Sub trees 6/16
  6. Git trees File systems are trees We only have blobs

    Time to build some trees! $ git ls-tree HEAD 100644 blob 7055....eebf2890a42 presentation.tex 100644 blob e527....127c87f80b4 settings.tex 040000 tree f556....a1a42929a28 figures 100644 blob 2edd....f8b09467a29 Makefile 7/16
  7. Git trees File systems are trees We only have blobs

    Time to build some trees! $ git ls-tree HEAD 100644 blob 7055....eebf2890a42 presentation.tex 100644 blob e527....127c87f80b4 settings.tex 040000 tree f556....a1a42929a28 figures 100644 blob 2edd....f8b09467a29 Makefile $ git rev-parse HEAD 9d8964533686208bbc54e9f2d3845884ccbb9f90 A tree is a ’blob’ too! 7/16
  8. Commits in Git $ git cat-file commit 9d896453368...e9f2d3845884ccbb9f90 tree a92824742feb5c35c6c4ccbfa56439c16bae4aad

    author Maarten <[email protected]> 1362089614 +0100 Initial version of CV $ git rev-parse HEAD 9d8964533686208bbc54e9f2d3845884ccbb9f90 Commit is a ’blob’ too! (Just like trees) 10/16
  9. Branches $ git cat-file commit 9d896453368...e9f2d3845884ccbb9f90 tree a92824742feb5c35c6c4ccbfa56439c16bae4aad author Maarten

    <[email protected]> 1362089614 +0100 (copied) $ git cat-file commit ‘git rev-parse HEAD‘ tree caf6e84ff8c195a339634b68786397b43ad00e1d parent 9d8964533686208bbc54e9f2d3845884ccbb9f90 author Maarten <[email protected]> 1362093020 +0100 Fix some spelling mistakes 11/16
  10. Branch names master foo bar $ ls .git/refs/heads master foo

    bar $ cat .git/refs/heads/master => ddf27254...2478b5e88b495 $ cat .git/refs/heads/foo => 770242f5...f14c69c7c514c $ cat .git/refs/heads/bar => ddf27254...2478b5e88b495 12/16
  11. How Does This Help Me? Nice to know Basis for

    understanding git Understand merge Understand rebase 13/16