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

Demystifying Git

Demystifying Git

Paulo Ancheta

April 24, 2018
Tweet

More Decks by Paulo Ancheta

Other Decks in Technology

Transcript

  1. 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.
  2. 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
  3. 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
  4. Git Object Type • none • Blob • Tree •

    Commit • Tag https://github.com/git/git/blob/master/object.c#L21-L27
  5. Git Object Type: Blob $ echo “hello world” | git

    hash-object -w --stdin 3b18e512dba79e4c8300dd08aeb37f8e728b8dad $ cd .git && tree ├── objects │ ├── 3b │ │ └── 18e512dba79e4c8300dd08aeb37f8e728b8dad │ ├── info │ └── pack
  6. Git Object Type: Blob $ git cat-file -s 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 12

    $ git cat-file -t 3b18e512dba79e4c8300dd08aeb37f8e728b8dad blob $ git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad hello world
  7. 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
  8. Git Object Type: Blob $ echo “hello world” > hello.txt

    $ git status Untracked files: (use "git add <file>..." to include in what will be committed) hello.txt
  9. Git Object Type: Tree $ git write-tree 68aba62e560c0ebc3396e8ae9335232cd93a3f60 $ git

    cat-file -t 68aba62e560c0ebc3396e8ae9335232cd93a3f60 Tree $ git cat-file -p 68aba62e560c0ebc3396e8ae9335232cd93a3f60 100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad hello.txt
  10. Git Commit • Author • Date • Tree • SHA

    • Commit message https://github.com/git/git/blob/master/commit.c#L1306-L1310
  11. 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
  12. 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
  13. Git Object Type: Commit $ cat .git/HEAD ref: refs/heads/master $

    find .git/refs refs refs/heads refs/tags
  14. Git Object Type: Commit $ git update-ref refs/heads/master bb429db985800c23d0b1773e844e846af8ab5fe7 $

    git log Commit bb429db985800c23d0b1773e844e846af8ab5fe7 My Initial Commit
  15. FakeGit: priv/object Just an initialize --------> Raise on type error

    -------> Other write methods are Private ------------------->
  16. 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