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

Git demystified for non-programmers

Git demystified for non-programmers

Git is a version control system that has become extremely popular over the last decade. While primarily intended to manage software source code, it is finding increasing usage for other purposes and by people with varying professional backgrounds. This talk will explain the basic concepts, terms, and workflows of Git, as well as a small amount of its internal design to help improve understanding for people who are not computer programmers by trade.

8893e2e206c0377ff776d2535887d23f?s=128

Jimmy Cuadra

June 15, 2016
Tweet

Transcript

  1. Git Demystified for non-programmers @jimmycuadra

  2. Disclaimers

  3. Distributed version control

  4. Initial version Revision 1 Revision 2

  5. Why should a writer care?

  6. EXAMPLE CONVENTIONS

  7. File / Tree Commit / Ref Repository

  8. $ tree . !"" chapters # !"" chapter_1.txt # !""

    chapter_2.txt # $"" chapter_3.txt !"" intro.txt $"" outro.txt
  9. $ git init Initialized empty Git repository in /Users/jimmy/Code/git- demystified/.git/

    $ git commit -m "Add intro, outro, and three chapters." [master (root-commit) bbedcbe] Add intro, outro, and three chapters. 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 chapters/chapter_1.txt create mode 100644 chapters/chapter_2.txt create mode 100644 chapters/chapter_3.txt create mode 100644 intro.txt create mode 100644 outro.txt
  10. GIT REPOSITORIES

  11. Blobs

  12. Blob Blob Blob Blob Blob Blob Blob Blob

  13. jpeg text wav markdown html doc py exe

  14. Trees

  15. Derrick Coetzee / Wikimedia Commons / Public Domain

  16. $ git commit -m "Add intro, outro, and three chapters."

    [master (root-commit) bbedcbe] Add intro, outro, and three chapters. $ git cat-file -p e0e642a 040000 tree 5938ce63424981f08d17edff734614a825f781e2 chapters 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 intro.txt 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 outro.txt $ git cat-file -p 5938ce6 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 chapter_1.txt 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 chapter_2.txt 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 chapter_3.txt
  17. Commits

  18. Commit Tree Metadata

  19. $ git commit -m "Add intro, outro, and three chapters."

    [master (root-commit) bbedcbe] Add intro, outro, and three chapters. 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 chapters/chapter_1.txt create mode 100644 chapters/chapter_2.txt create mode 100644 chapters/chapter_3.txt create mode 100644 intro.txt create mode 100644 outro.txt
  20. $ git cat-file -p bbedcbe tree e0e642ac3334754ff3f49e7ec6aa25241bdeeeda author Jimmy Cuadra

    <jimmy@jimmycuadra.com> 1458099001 -0700 committer Jimmy Cuadra <jimmy@jimmycuadra.com> 1458099001 -0700 Add intro, outro, and three chapters.
  21. Repository

  22. Database of Git Objects

  23. Repository Blob Blob Tree Commit

  24. History

  25. Commit Commit Commit Commit Commit Commit

  26. THE THREE STATES

  27. Working directory

  28. $ git status On branch master Initial commit Untracked files:

    (use "git add <file>..." to include in what will be committed) chapters/ intro.txt outro.txt nothing added to commit but untracked files present (use "git add" to track)
  29. Staging area (Index)

  30. $ git add intro.txt

  31. $ git status On branch master Initial commit Changes to

    be committed: (use "git rm --cached <file>..." to unstage) new file: intro.txt Untracked files: (use "git add <file>..." to include in what will be committed) chapters/ outro.txt
  32. $ git add .

  33. $ git status On branch master Initial commit Changes to

    be committed: (use "git rm --cached <file>..." to unstage) new file: chapters/chapter_1.txt new file: chapters/chapter_2.txt new file: chapters/chapter_3.txt new file: intro.txt new file: outro.txt
  34. Git Repository

  35. $ git commit -m "Add intro, outro, and three chapters."

    [master (root-commit) bbedcbe] Add intro, outro, and three chapters. 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 chapters/chapter_1.txt create mode 100644 chapters/chapter_2.txt create mode 100644 chapters/chapter_3.txt create mode 100644 intro.txt create mode 100644 outro.txt
  36. $ git status On branch master nothing to commit, working

    directory clean
  37. $ git log commit bbedcbefe51e206723ab5621d1717a660b8c0374 Author: Jimmy Cuadra <jimmy@jimmycuadra.com> Date:

    Tue Mar 15 20:30:01 2016 -0700 Add intro, outro, and three chapters.
  38. GIT REFS

  39. Pixabay / Public Domain Jim Jimmy James Hey you Dork

    @jimmycuadra
  40. SHA-1 $ git show -1 commit bbedcbefe51e206723ab5621d1717a660b8c0374 Author: Jimmy Cuadra

    <jimmy@jimmycuadra.com> Date: Tue Mar 15 20:30:01 2016 -0700 Add intro, outro, and three chapters.
  41. HEAD Commit Commit Commit Commit Commit Commit

  42. Branches

  43. m1 m2 m3 master HEAD

  44. m1 m2 m3 master HEAD my-feature

  45. Tags

  46. m1 m2 m3 master HEAD

  47. m1 m2 m3 master HEAD v1.0.0 “First release”

  48. MERGING BRANCHES

  49. m1 m2 m3 master HEAD

  50. m1 m2 m3 master HEAD bad-idea

  51. m1 m2 m3 master bad-idea HEAD

  52. m1 m2 m3 master bad-idea c1 HEAD

  53. m1 m2 m3 master HEAD bad-idea c1 c2

  54. m1 m2 m3 master HEAD bad-idea c1 c2 “Fast forward

    merge”
  55. m1 m2 m3 master HEAD bad-idea c1 c2

  56. m1 m2 m3 master HEAD bad-idea c1 c2

  57. m1 m2 m3 master HEAD bad-idea c1 c2 m4

  58. m1 m2 m3 master HEAD bad-idea c1 c2 m4 m5

  59. m1 m2 m3 master HEAD c1 c2 m4 m5

  60. m1 m2 m3 master HEAD c1 c2 m4 m5 m6

  61. DISTRIBUTED GIT

  62. Repository File File File File Alice File File Bob File

    File Carol
  63. Alice Repository File File Bob Repository File File Carol Repository

    File File
  64. Remotes

  65. Alice Repository alice1

  66. origin Repository alice1 Bob Repository alice1 $ git clone https://alice.example.com/repo.git

  67. origin Repository alice1 Bob Repository alice1 $ git commit -m

    “Make some changes” bob1
  68. origin Repository alice1 Bob Repository alice1 $ git remote add

    carol https://carol.example.com/repo.git $ git fetch carol bob1 carol Repository alice1 carol1
  69. origin Repository alice1 Bob Repository alice1 $ git merge carol/master

    bob1 carol Repository alice1 carol1 carol1
  70. CLOSING ADVICE

  71. Git is complicated software, but built on many simple concepts

  72. Don’t try to remember every single command

  73. Learn only what you need as you need it

  74. Remember that the concepts are simple, even when the interface

    seems complicated
  75. Git is a history of snapshots of your project at

    each state throughout its life
  76. THANK YOU @jimmycuadra Git logo: Jason Long / https://git-scm.com/downloads/logos /

    Creative Commons Attribution 3.0