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

Git for everyone

Git for everyone

Unless you have been living in a cave, Git is everywhere. Creative or engineering, you have directly encountered or will encounter Git in the workplace. A common misconception as well is that Git is only for teams? Regardless of work style or team size, Git is the tool that everyone should be using.

Get the Book
https://www.gitbook.io/book/anotheruiguy/gitforeveryone

Dale Sande

June 18, 2014
Tweet

More Decks by Dale Sande

Other Decks in Programming

Transcript

  1. Git
    the Git Workshop
    learn

    View full-size slide



  2. speakerdeck.com/anotheruiguy/
    git-for-everyone

    View full-size slide



  3. gitbook.io/book/anotheruiguy/
    gitforeveryone

    View full-size slide

  4. That’s me!
    That’s where !
    I ‘work’
    @ANOTHERUIGUY
    That’s a ninja

    View full-size slide



  5. why so hard?

    View full-size slide

  6. How can I
    get to that
    file?

    View full-size slide

  7. How can I
    get to that
    file?
    Just open
    Terminal and then $
    cd ~/Projects/
    boilerplate/ &&
    vi .gitignore

    View full-size slide

  8. How can I
    get to that
    file?
    Just open
    Terminal and then $
    cd ~/Projects/
    boilerplate/ &&
    vi .gitignore
    OMG!
    That is
    weird? What
    do I do?

    View full-size slide

  9. How can I
    get to that
    file?
    Just open
    Terminal and then $
    cd ~/Projects/
    boilerplate/ &&
    vi .gitignore
    OMG!
    That is
    weird? What
    do I do?
    Geeze, press the i key, go
    to this line and add <file
    path>/**/*. Then hit the esc
    key to save. To get out,
    type :wq, ok!?

    View full-size slide

  10. How can I
    get to that
    file?
    Just open
    Terminal and then $
    cd ~/Projects/
    boilerplate/ &&
    vi .gitignore
    OMG!
    That is
    weird? What
    do I do?
    Geeze, press the i key, go
    to this line and add <file
    path>/**/*. Then hit the esc
    key to save. To get out,
    type :wq, ok!?

    View full-size slide

  11. Terminal Cheatsheet for Mac

    View full-size slide

  12. Open files in VI
    $ touch index.html

    View full-size slide

  13. Open files in VI
    $ touch index.html
    $ vi index.html

    View full-size slide

  14. Open files in VI
    $ touch index.html
    $ vi index.html
    i

    View full-size slide

  15. Open files in VI
    $ touch index.html
    $ vi index.html
    i
    esc + :wq

    View full-size slide

  16. Open files in VI
    $ touch index.html
    $ vi index.html
    i
    esc + :wq

    View full-size slide

  17. Before VC or Branching
    my-project-folder
    YAY! My
    project!

    View full-size slide

  18. Before VC or Branching
    my-project-folder
    I need to
    update my
    project

    View full-size slide

  19. Before VC or Branching
    my-project-folder
    I need to
    update my
    project
    my-project-folder-copy

    View full-size slide

  20. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    Yup, need
    another
    version

    View full-size slide

  21. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    Yup, need
    another
    version
    my-project-folder-copy-v2

    View full-size slide

  22. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    my-project-folder-copy-v2
    Need to
    revert some
    code ;(

    View full-size slide

  23. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    my-project-folder-copy-v2
    Need to
    revert some
    code ;(
    Crap!
    Which folder
    has the right
    stuff?

    View full-size slide

  24. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    my-project-folder-copy-v2
    Need to
    revert some
    code ;(
    Crap!
    Which folder
    has the right
    stuff?
    Ok, get
    these lines and
    then …

    View full-size slide

  25. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    my-project-folder-copy-v2
    Need to
    revert some
    code ;(
    Crap!
    Which folder
    has the right
    stuff?
    Ok, get
    these lines and
    then …
    NOTHING
    IS
    WORKING!!

    View full-size slide

  26. Before VC or Branching
    my-project-folder
    my-project-folder-copy
    my-project-folder-copy-v2
    Need to
    revert some
    code ;(
    Crap!
    Which folder
    has the right
    stuff?
    Ok, get
    these lines and
    then …
    NOTHING
    IS
    WORKING!!
    Boss: Hey, we have a
    new person you will work
    with. You need to share code
    and work on solving problems
    together. !
    !
    You: SHIT! Dropbox, why
    you no scale?

    View full-size slide

  27. Inexpensive versioning
    master

    View full-size slide

  28. Inexpensive versioning
    master

    View full-size slide

  29. Inexpensive versioning
    master
    feature-branch

    View full-size slide

  30. Inexpensive versioning
    master
    feature-branch

    View full-size slide

  31. Inexpensive versioning
    master
    feature-branch
    feature-branch

    View full-size slide

  32. Inexpensive versioning
    master
    feature-branch
    feature-branch

    View full-size slide

  33. Inexpensive versioning
    master
    feature-branch
    feature-branch

    View full-size slide

  34. Inexpensive versioning
    master
    feature-branch
    feature-branch

    View full-size slide

  35. Forking and Cloning

    View full-size slide

  36. Forking and Cloning
    $ git clone [email protected]:blackfalcon/label-reveal.git

    View full-size slide

  37. Forking and Cloning
    Source

    View full-size slide

  38. Forking and Cloning
    Source
    Your fork

    View full-size slide

  39. Forking and Cloning
    Source
    Your fork
    feature-branch
    feature-branch

    View full-size slide

  40. Forking and Cloning
    Source
    Your fork
    feature-branch
    feature-branch

    View full-size slide

  41. Forking and Cloning
    Source
    Your fork
    feature-branch
    feature-branch
    The Pull Request

    View full-size slide


  42. branching and merging

    View full-size slide

  43. $ git branch

    View full-size slide

  44. $ git branch
    $ git checkout master

    View full-size slide

  45. $ git branch
    $ git checkout master
    $ git pull origin master

    View full-size slide

  46. $ git branch
    $ git checkout master
    $ git pull origin master
    $ git checkout -b my-new-feature-branch

    View full-size slide

  47. $ git branch
    $ git checkout master
    $ git pull origin master
    $ git checkout -b my-new-feature-branch
    $ git checkout -b transaction-fail-message master

    View full-size slide

  48. $ git status

    View full-size slide

  49. $ git status
    $ git add .

    View full-size slide

  50. $ git status
    $ git add .
    $ git add -u

    View full-size slide

  51. $ git status
    $ git add .
    $ git add -u
    $ git add --all

    View full-size slide

  52. $ git status
    $ git add .
    $ git add -u
    $ git add --all
    $ git commit -m "a commit message in the present tense"

    View full-size slide

  53. $ git commit -m "fixed bug with login feature"


    View full-size slide

  54. $ git commit -m "fixed bug with login feature"


    View full-size slide

  55. $ git commit -m "fixed bug with login feature"


    $ git commit -m "update app config to address login bug"

    View full-size slide

  56. $ git branch -r << this will list remote branches


    View full-size slide

  57. $ git branch -r << this will list remote branches
    $ git fetch -p << this will prune your local index


    View full-size slide

  58. $ git branch -r << this will list remote branches
    $ git fetch -p << this will prune your local index


    $ git checkout new-remote-feature-branch

    View full-size slide

  59. $ git checkout my-feature-branch


    View full-size slide

  60. $ git checkout my-feature-branch
    $ git pull origin my-feature-branch


    View full-size slide

  61. $ git checkout my-feature-branch
    $ git pull origin my-feature-branch


    $ git pull origin master

    View full-size slide

  62. $ git checkout master


    View full-size slide

  63. $ git checkout master
    $ git pull origin master


    View full-size slide

  64. $ git checkout master
    $ git pull origin master


    $ git merge --no-ff my-feature-branch

    View full-size slide

  65. $ cd ~/Desktop

    View full-size slide

  66. $ cd ~/Desktop
    $ mkdir gitDemo

    View full-size slide

  67. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status

    View full-size slide

  68. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status
    $ git init

    View full-size slide

  69. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status
    $ git init
    $ git status

    View full-size slide

  70. $ touch index.html

    View full-size slide

  71. $ touch index.html
    $ mkdir stylesheets

    View full-size slide

  72. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts

    View full-size slide

  73. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts
    $ cd stylesheets && touch app.css && cd ../

    View full-size slide

  74. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts
    $ cd stylesheets && touch app.css && cd ../
    $ cd javascripts && touch app.js && cd ../

    View full-size slide

  75. $ mkdir foo
    $ git status



    View full-size slide

  76. $ mkdir foo
    $ git status
    $ rm -rf foo



    View full-size slide

  77. Hello World
    h1 { font-size: 8em; }

    View full-size slide

  78. Hello World
    h1 { font-size: 8em; }
    var today = new Date()

    View full-size slide

  79. $ git add .
    $ git status

    View full-size slide

  80. $ git add .
    $ git status
    $ git commit -m "update to function ..."

    View full-size slide

  81. $ git add .
    $ git status
    $ git commit -m "update to function ..."
    $ git status

    View full-size slide

  82. $ git add .
    $ git status
    $ git commit -m "update to function ..."
    $ git status
    # On branch master nothing to commit …

    View full-size slide

  83. $ git log
    $ git blame index.html


    View full-size slide

  84. $ git log
    $ git blame index.html
    ^15d42d5 (Dale Sande 2014-06-10 18:25:26 -0700 1)


    View full-size slide

  85. $ git branch

    View full-size slide

  86. $ git branch
    $ git checkout -b new-branch

    View full-size slide

  87. $ git branch
    $ git checkout -b new-branch
    goodnight moon

    View full-size slide

  88. $ git branch
    $ git checkout -b new-branch
    goodnight moon
    p { font-size: 2em; }

    View full-size slide

  89. $ git branch
    $ git checkout -b new-branch
    goodnight moon
    p { font-size: 2em; }
    $ git status

    View full-size slide

  90. $ git add .
    $ git commit -m "update content and styles"



    View full-size slide

  91. $ git add .
    $ git commit -m "update content and styles"
    $ git checkout master



    View full-size slide

  92. $ git checkout master


    View full-size slide

  93. $ git checkout master
    $ git branch --merged


    View full-size slide

  94. $ git checkout master
    $ git branch --merged
    $ git branch --no-merged


    View full-size slide

  95. $ git merge new-branch --no-ff


    View full-size slide

  96. $ git merge new-branch --no-ff
    :wq


    View full-size slide

  97. $ git merge new-branch --no-ff
    :wq
    $ git branch --merged


    View full-size slide


  98. fork all the codes

    View full-size slide


  99. clone all the codes

    View full-size slide


  100. you Git awesome!

    View full-size slide

  101. $ which git



    If a version of Git is not there!

    View full-size slide

  102. $ brew install git



    this is pretty metal

    View full-size slide

  103. $ brew install git



    this is pretty metal
    PATH=/usr/local/bin:$PATH
    That goes in your
    ~/.bash_profile bro!

    View full-size slide

  104. $ cd ~/Desktop

    View full-size slide

  105. $ cd ~/Desktop
    $ mkdir gitDemo

    View full-size slide

  106. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status

    View full-size slide

  107. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status
    $ git init

    View full-size slide

  108. $ cd ~/Desktop
    $ mkdir gitDemo
    $ cd gitDemo && git status
    $ git init
    $ git status

    View full-size slide

  109. $ touch index.html

    View full-size slide

  110. $ touch index.html
    $ mkdir stylesheets

    View full-size slide

  111. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts

    View full-size slide

  112. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts
    $ cd stylesheets && touch app.css && cd ../

    View full-size slide

  113. $ touch index.html
    $ mkdir stylesheets
    $ mkdir javascripts
    $ cd stylesheets && touch app.css && cd ../
    $ cd javascripts && touch app.js && cd ../

    View full-size slide

  114. $ mkdir foo
    $ git status



    View full-size slide

  115. $ mkdir foo
    $ git status
    $ rm -rf foo



    View full-size slide


  116. Hello World
    That goes in your
    index.html

    View full-size slide


  117. Hello World
    That goes in your
    index.html
    h1 { font-size: 8em; }
    That goes in your
    app.css

    View full-size slide


  118. Hello World
    That goes in your
    index.html
    h1 { font-size: 8em; }
    That goes in your
    app.css
    var today = new Date()
    That goes in your
    app.js

    View full-size slide

  119. $ git add .
    $ git status

    View full-size slide

  120. $ git add .
    $ git status
    $ git commit -m "update to function ..."

    View full-size slide

  121. $ git add .
    $ git status
    $ git commit -m "update to function ..."
    $ git status

    View full-size slide

  122. $ git add .
    $ git status
    $ git commit -m "update to function ..."
    $ git status
    # On branch master nothing to commit …

    View full-size slide

  123. $ git log
    $ git blame index.html


    View full-size slide

  124. $ git log
    $ git blame index.html
    ^15d42d5 (Dale Sande 2014-06-10 18:25:26 -0700 1)


    View full-size slide

  125. $ git branch

    View full-size slide

  126. $ git branch
    $ git checkout -b new-branch

    View full-size slide

  127. $ git branch
    $ git checkout -b new-branch
    goodnight moon

    View full-size slide

  128. $ git branch
    $ git checkout -b new-branch
    goodnight moon
    p { font-size: 2em; }

    View full-size slide

  129. $ git branch
    $ git checkout -b new-branch
    goodnight moon
    p { font-size: 2em; }
    $ git status

    View full-size slide

  130. $ git add .
    $ git commit -m "update content and styles"



    View full-size slide

  131. $ git add .
    $ git commit -m "update content and styles"
    $ git checkout master



    View full-size slide

  132. $ git checkout master


    View full-size slide

  133. $ git checkout master
    $ git branch --merged


    View full-size slide

  134. $ git checkout master
    $ git branch --merged
    $ git branch --no-merged


    View full-size slide

  135. $ git merge new-branch --no-ff


    View full-size slide

  136. $ git merge new-branch --no-ff
    :wq


    View full-size slide

  137. $ git merge new-branch --no-ff
    :wq
    $ git branch --merged


    View full-size slide

  138. $ git log --abbrev-commit --graph"


    View full-size slide


  139. come Git more!

    View full-size slide