Slide 1

Slide 1 text

Helvetica

Slide 2

Slide 2 text

Demystifying Git

Slide 3

Slide 3 text

@pauloancheta

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Gili Trawangan, Indonesia

Slide 9

Slide 9 text

Demystifying Git

Slide 10

Slide 10 text

What is Git?! Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

What is Git?! ● Random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant. ● stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang. ● "global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room. ● "goddamn idiotic truckload of sh*t": when it breaks

Slide 13

Slide 13 text

Lego

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Lego ● Consists of small pieces ● Each pieces are extensible ● Easily torn apart ● It has pins and connectors so they can be attached to a different piece

Slide 16

Slide 16 text

Git Objects

Slide 17

Slide 17 text

Git Object Type ● none ● Blob ● Tree ● Commit ● Tag https://github.com/git/git/blob/master/object.c#L21-L27

Slide 18

Slide 18 text

Git Object Type: Blob

Slide 19

Slide 19 text

Git Object Type: Blob $ echo “hello world” | git hash-object -w --stdin 3b18e512dba79e4c8300dd08aeb37f8e728b8dad $ cd .git && tree ├── objects │ ├── 3b │ │ └── 18e512dba79e4c8300dd08aeb37f8e728b8dad │ ├── info │ └── pack

Slide 20

Slide 20 text

Git Object Type: Blob $ git cat-file -s 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 12 $ git cat-file -t 3b18e512dba79e4c8300dd08aeb37f8e728b8dad blob $ git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad hello world

Slide 21

Slide 21 text

Git Object Type: Blob $ git update-index --add --cache-info 100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad hello.txt $ git status Changes to be committed: new file: hello.txt Changes not staged for commit: deleted: hello.txt

Slide 22

Slide 22 text

Git Object Type: Blob $ echo “hello world” > hello.txt $ git status Untracked files: (use "git add ..." to include in what will be committed) hello.txt

Slide 23

Slide 23 text

Git Object Type: Tree

Slide 24

Slide 24 text

Git Object Type: Tree $ git write-tree 68aba62e560c0ebc3396e8ae9335232cd93a3f60 $ git cat-file -t 68aba62e560c0ebc3396e8ae9335232cd93a3f60 Tree $ git cat-file -p 68aba62e560c0ebc3396e8ae9335232cd93a3f60 100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad hello.txt

Slide 25

Slide 25 text

Git Object Type: Commit

Slide 26

Slide 26 text

Git Commit ● Author ● Date ● Tree ● SHA ● Commit message https://github.com/git/git/blob/master/commit.c#L1306-L1310

Slide 27

Slide 27 text

Git Object Type: Commit $ git commit-tree 68aba62e560c0ebc3396e8ae9335232cd93a3f60 -m “My Initial Commit” $ git log fatal: your current branch 'master' does not have any commits yet

Slide 28

Slide 28 text

Git HEAD

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

ae3aedc Initial commit f54f95f I guess it works now, but I have no idea why 8308941 Changes because John said so f3a1c80 Fix failures because of John’s comment eb0d8ef ZOMG please don’t ask me

Slide 31

Slide 31 text

Git Object Type: Commit $ cat .git/HEAD ref: refs/heads/master $ find .git/refs refs refs/heads refs/tags

Slide 32

Slide 32 text

Git Object Type: Commit $ git update-ref refs/heads/master bb429db985800c23d0b1773e844e846af8ab5fe7 $ git log Commit bb429db985800c23d0b1773e844e846af8ab5fe7 My Initial Commit

Slide 33

Slide 33 text

We made our first commit!

Slide 34

Slide 34 text

Demystifying Git Using Ruby

Slide 35

Slide 35 text

FakeGit gem install fake_git

Slide 36

Slide 36 text

FakeGit: Init $ fakegit init $ fakegit init my-repo

Slide 37

Slide 37 text

FakeGit: Handling Executable ./exe/fakegit* Handle no stdin ------------> With stdin ----------------->

Slide 38

Slide 38 text

FakeGit: Handling Executable ZOMG IS THAT A GLOBAL? ------>

Slide 39

Slide 39 text

FakeGit: Handling Different Commands Constantize ---->

Slide 40

Slide 40 text

FakeGit: Init $ fakegit init $ fakegit init my-repo

Slide 41

Slide 41 text

FakeGit: hash-object Obj can write To storage -------------->

Slide 42

Slide 42 text

FakeGit: priv/object Just an initialize --------> Raise on type error -------> Other write methods are Private ------------------->

Slide 43

Slide 43 text

OG Git: db storage Original git /objects/\w\w/\w*/

Slide 44

Slide 44 text

FakeGit: db storage .fakegit/objects/\w\w/\w*/ Comma separated values. key=value format

Slide 45

Slide 45 text

FakeGit: fetch-object Build a new object from File -------------------->

Slide 46

Slide 46 text

FakeGit: list-objects

Slide 47

Slide 47 text

FakeGit: update-index

Slide 48

Slide 48 text

FakeGit: Log

Slide 49

Slide 49 text

Magic

Slide 50

Slide 50 text

Sources Advanced Git Tutorial ● https://www.youtube.com/watch?v=0SJCYPsef54 Git Repository ● https://github.com/git/git Git Internals - Git References ● https://git-scm.com/book/en/v2/Git-Internals-Git-Referenc es Git Internals - Git Objects ● https://git-scm.com/book/en/v2/Git-Internals-Git-Objects StackOverflow git HEAD(~ vs ^ vs @{}) ● https://stackoverflow.com/questions/26785118/head-vs-he ad-vs-head-also-known-as-tilde-vs-caret-vs-at-sign/267852 00

Slide 51

Slide 51 text

@pauloancheta Thank You!