Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GitHub for the Rest of Us

6,344 views

Published on

Slides from Morten Rand-Hendriksen's WordCamp US 2015 talk:

GitHub is that awesome thing everyone says you’ve gotta use, but how many of us can make heads or tails of it? If you’re tired of pretending to understand when someone talks about “merging the latest pull request” or want to know what the heck forks have to do with code, this rundown’s for you.

I’ll show you how a little dose of science fiction is the key to understanding Version Control. There will be teleportation, time travel, there may even be a victimless murder as you learn the difference between a Fetch and a Pull, why Rebasing changes history, and how merging branches can magically reconcile conflicting code.

Whether you develop, design, or just care about content, Git, GitHub, and Version Control can be some of the most useful tools in your kit. After this primer, you’ll see why Git and GitHub is for everyone, including you.

Published in: Internet
  • Hey guys! Who wants to chat with me? More photos with me here 👉 http://www.bit.ly/katekoxx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Nice !! Download 100 % Free Ebooks, PPts, Study Notes, Novels, etc @ https://www.ThesisScientist.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi, I really liked this presentation. Is it possible to find the slides in ppt or pdf format on your blog somewhere?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

GitHub for the Rest of Us

  1. 1. Github for the Rest of Us or: how i learned to stop worrying and love version control by Morten Rand-Hendriksen
  2. 2. !@MOR10
  3. 3. http://www.xkcd.com/1597/
  4. 4. SOLVES EVERYTHING
  5. 5. Say you find yourself in space
  6. 6. On a ship hauling valuable materials from an astroid.
  7. 7. And there’s a huge hole in your oxygen supply.
  8. 8. You could go outside and fix it, but theres a big crack in your jetpack as well.
  9. 9. If you don’t do something, your oxygen will run out.
  10. 10. And if that wasn’t bad enough,
  11. 11. The only patch kit on the ship is outside, on the hull. But to patch both the jetpack and the oxygen tank, you need TWO patch kits.
  12. 12. This is one of those times when a cloning machine would come in real handy.
  13. 13. But here’s the thing. We actually have a cloning machine. And it can do a lot more than just clone. It can also help us travel through time!
  14. 14. First thing’s first: Before you do anything else, you need to commit the current state to memory, sort of like a save point in a game.
  15. 15. This first commit becomes an anchor point in time you can always go back to.
  16. 16. git checkout -b get_patch_kit Then, you can create an alternate timeline and jump to it.
  17. 17. Now, in that alternate timeline, you can start experimenting: To patch the air leak, you have to get the patch kit outside the ship. So let’s see if you can just jump outside and grab it without the spacesuit.
  18. 18. release the airlock and PWHOSHHHHH Get ejected into space…
  19. 19. … to float around for eternity as a piece of frozen space junk. OK, so that didn’t work.
  20. 20. Doesn’t matter. You’re on an alternate timeline, so you can just jump back in time to the original commit and start over!
  21. 21. git checkout -b get_patch_kit_secure Let’s try that again. Make a new alternate timeline, and this time take some precautions.
  22. 22. Before releasing the airlock, you tether yourself to the ship
  23. 23. so when the air rushes out, you won’t just get ejected
  24. 24. Swing yourself out of the airlock and grab the patch kit…
  25. 25. … stuff it in your giant spacesuit kangaroo pocket…
  26. 26. … and drift into space like a frozen piece of space junk. Only this time, you have the patch kit!
  27. 27. git checkout master You see now you can travel back in time …
  28. 28. … to before you went outside the ship …
  29. 29. … hit the “Merge” button …
  30. 30. git merge --no-ff get_patch_kit_secure …and merge the two timelines together!
  31. 31. When the timelines merge, the patch kit from the timeline where you picked it up becomes part of the current timeline.
  32. 32. Now you can patch your jetpack …
  33. 33. … put on your spacesuit …
  34. 34. git commit -m “going outside” … commit a new save point …
  35. 35. … cycle through the airlock …
  36. 36. … and grab the patch kit from the outside (because we are now on the original timeline where we have yet to use it).
  37. 37. git checkout -b repair_tanks Create a new alternate timeline for the tank repair …
  38. 38. … and start repairing the tank.
  39. 39. But there’s a problem! The patch kit is only enough to repair half the leak!
  40. 40. git commit -m “patch 50% complete” Not a problem. Simply commit the current 50% complete patch …
  41. 41. git checkout master Jump back in time to when you first picked up the patch kit.
  42. 42. git merge --no-ff repair_tanks Merge the 50% patch to the current timeline.
  43. 43. Now the leak is half resolved.
  44. 44. git checkout -b repair_tanks_v2git checkout -b repair_tanks_v2 To fix the rest of the leak, you have to go back in time to before you picked up the patch kit …
  45. 45. git checkout -b repair_tanks_v2git checkout going_outside … create a new branch from the main timeline, where the patch kit has not yet been used …
  46. 46. … cycle through the airlock …
  47. 47. … and grab the patch kit from the outside (because we are now on a new timeline where we have yet to use it).
  48. 48. Go back and patch the tank from the other side.
  49. 49. Now you have a patch that covers the other 50% of the leak.
  50. 50. git commit -m “other 50% patched. possible conflict” Commit a new save point for the other 50% patch.
  51. 51. git checkout master Checkout the previous merge point …
  52. 52. Hit the merge button again …
  53. 53. git merge --no-ff repair_tank_v2 … and merge the new patch to the main timeline. But there’s a conflict!
  54. 54. The two patches overlap and a merge can’t be completed.
  55. 55. To resolve the conflict, go back outside…
  56. 56. … identify the conflict …
  57. 57. … and resolve it by changing one of the patches to remove the overlap.
  58. 58. git commit -m “patch conflict resolved” Now you can commit the final merge which serves as the save point for the finished patch. And that’s it! Problem solved!
  59. 59. Except when you move to take your spacesuit off, an alarm sounds!
  60. 60. And your friendly AI gives you the most confusing message: “Are you sure you want to do that?”
  61. 61. OK, so obviously something is wrong, but what?
  62. 62. Glancing over at the oxygen meter, you see the problem. While you’ve been patching the leak, all the oxygen has disappeared.
  63. 63. git checkout “first commit” Not a problem! Just checkout the first commit …
  64. 64. … back when the oxygen leak had just started …
  65. 65. … and the oxygen supply was still at 70% …
  66. 66. git checkout -b air_supply Create a new branch called “air_supply” …
  67. 67. git commit -m “making love out of nothing at all” … commit a new save point with our 70% full air tank …
  68. 68. git rebase master … and rewrite history by rebasing the new save point to the top of our current timeline.
  69. 69. Using Git, we’ve used the same patch kit three times to fix the jetpack and the air leak (twice), and borrowed an air supply from the past to top off our tanks.
  70. 70. SOLVES EVERYTHING
  71. 71. SOLVES EVERYTHING
  72. 72. on your computer in the cloud
  73. 73. REPOSITORY The universe in which your project exists.
  74. 74. git commit Create a snapshot, or save point, to which you can always return. Commits
  75. 75. git branch An alternate timeline within the current universe. Branches
  76. 76. git checkout Your personal time machine. Checkout allows you to jump to any commit on any branch, in your current universe or any other universe.
  77. 77. git merge Merge the contents of one timeline into another.
  78. 78. CONFLICT Changes have taken place in both both timelines after they were split apart. You must decide what change to keep and what change to discard.
  79. 79. git rebase Rewrite history by tacking the events of one timeline onto another as if they were always there.
  80. 80. git rebase Rewrite history by tacking the events of one timeline onto another as if they were always there.
  81. 81. git fork An alternate universe that starts as an exact copy of the one you forked.
  82. 82. git clone Make a duplicate copy of an external universe and place it in the current one. Empty repo
  83. 83. git clone Make a duplicate copy of an external universe and place it in the current one. Clone
  84. 84. git push Physically push your commits to another repository (typically Github) Push Local Remote
  85. 85. git fetch Grab the current version of an external timeline and open it. Local Remote Fetch
  86. 86. git pull Grab the current version of an external timeline and merge it with the current timeline. Local Remote Pull
  87. 87. DETACHED HEAD Before using the time machine, changes were made without being committed, thereby detaching them. Create a new timeline to restore reality. Uncommitted change
  88. 88. DETACHED HEAD Before using the time machine, changes were made without being committed, thereby detaching them. Create a new timeline to restore reality. Checkout
  89. 89. DETACHED HEAD Before using the time machine, changes were made without being committed, thereby detaching them. Create a new timeline to restore reality. Detached head
  90. 90. DETACHED HEAD Before using the time machine, changes were made without being committed, thereby detaching them. Create a new timeline to restore reality. Fix with new branch
  91. 91. Don’t let the command line deter you. There are better options!
  92. 92. desktop.github.com
  93. 93. sourcetreeapp.com
  94. 94. SOLVES EVERYTHING
  95. 95. Get a free 10-day trial: lynda.com/trial/mor10

×