Pragmatic Guide to Git

2,259 views
2,126 views

Published on

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,259
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
76
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Pragmatic Guide to Git

  1. 1. Pragmatic GuideGIT Travis Swicegood #gittalkLicensed under Creative Commons, Attribution, Share-Alike
  2. 2. #gittalkpragmatic guide to git by travis swicegood some rights reserved
  3. 3. Hi, I’m Travispragmatic guide to git by travis swicegood some rights reserved
  4. 4. pragmatic guide to git by travis swicegood some rights reserved
  5. 5. Git is Easypragmatic guide to git by travis swicegood some rights reserved
  6. 6. What’s this talk about?pragmatic guide to git by travis swicegood some rights reserved
  7. 7. What this talk isn’t about?pragmatic guide to git by travis swicegood some rights reserved
  8. 8. Contentspragmatic guide to git by travis swicegood some rights reserved
  9. 9. Starting Outpragmatic guide to git by travis swicegood some rights reserved
  10. 10. Daily Workpragmatic guide to git by travis swicegood some rights reserved
  11. 11. Branchespragmatic guide to git by travis swicegood some rights reserved
  12. 12. Team Workpragmatic guide to git by travis swicegood some rights reserved
  13. 13. Glossarypragmatic guide to git by travis swicegood some rights reserved
  14. 14. Starting Outpragmatic guide to git by travis swicegood some rights reserved
  15. 15. Installationpragmatic guide to git by travis swicegood some rights reserved
  16. 16. Installation–Compiling … download latest source from git-scm.com… prompt> make && make install … if you’re adventurous… prompt> make docs && make install-docspragmatic guide to git by travis swicegood some rights reserved
  17. 17. Installation–Ubuntu prompt> apt-get install git-core … optional … prompt> apt-get install git-doc git-svnpragmatic guide to git by travis swicegood some rights reserved
  18. 18. Installation–Windows Cygwin: http://cygwin.org msysGit: http://code.google.com/p/msysgit/pragmatic guide to git by travis swicegood some rights reserved
  19. 19. Installation–OS X prompt> brew install git –OR– Git OS X Installer: http://code.google.com/p/git-osx-installer/pragmatic guide to git by travis swicegood some rights reserved
  20. 20. Verifying the Install prompt> git --version git version 1.7.3.2pragmatic guide to git by travis swicegood some rights reserved
  21. 21. My Version prompt> git --version git version 1.7.3.2 hub version 1.4.1pragmatic guide to git by travis swicegood some rights reserved
  22. 22. Getting Helppragmatic guide to git by travis swicegood some rights reserved
  23. 23. Built-in Help prompt> git help prompt> git help <some command> prompt> open http://j.mp/gitdocs/pragmatic guide to git by travis swicegood some rights reserved
  24. 24. Configurationpragmatic guide to git by travis swicegood some rights reserved
  25. 25. User & Email prompt> git config --global user.name “Travis Swicegood” prompt> git config --global user.email “travis@domain51.com”pragmatic guide to git by travis swicegood some rights reserved
  26. 26. Colors prompt> git config --global color.ui autopragmatic guide to git by travis swicegood some rights reserved
  27. 27. Creating New Repositoriespragmatic guide to git by travis swicegood some rights reserved
  28. 28. Repositorypragmatic guide to git by travis swicegood some rights reserved
  29. 29. Commitpragmatic guide to git by travis swicegood some rights reserved
  30. 30. Initialization prompt> git init … example … prompt> mkdir /work/some-repo prompt> cd /work/some-repo prompt> git initpragmatic guide to git by travis swicegood some rights reserved
  31. 31. Working Treepragmatic guide to git by travis swicegood some rights reserved
  32. 32. Cloning New Repositoriespragmatic guide to git by travis swicegood some rights reserved
  33. 33. Cloning prompt> git clone <some repo> … example … prompt> git clone git://github.com/tswicegood/bobby-tables.git prompt> cd bobby-tablespragmatic guide to git by travis swicegood some rights reserved
  34. 34. Cloning prompt> git clone <some repo> … example … prompt> git clone git://github.com/tswicegood/bobby-tables.git prompt> cd bobby-tablespragmatic guide to git by travis swicegood some rights reserved
  35. 35. Daily Workpragmatic guide to git by travis swicegood some rights reserved
  36. 36. Seeing What’s Changedpragmatic guide to git by travis swicegood some rights reserved
  37. 37. Status prompt> git status … example … prompt> git status # On branch master nothing to commit (working directory clean)pragmatic guide to git by travis swicegood some rights reserved
  38. 38. Staging Changespragmatic guide to git by travis swicegood some rights reserved
  39. 39. Indexpragmatic guide to git by travis swicegood some rights reserved
  40. 40. (aka) Staging Areapragmatic guide to git by travis swicegood some rights reserved
  41. 41. Adding a New File prompt> git status # On branch master # Untracked files: # (use "git add <file>..." to include in what… # # README.rstpragmatic guide to git by travis swicegood some rights reserved
  42. 42. Adding a New File prompt> git add README.rst prompt> git status # On branch master # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README.rstpragmatic guide to git by travis swicegood some rights reserved
  43. 43. Committing Changespragmatic guide to git by travis swicegood some rights reserved
  44. 44. Creating a Commit prompt> git commit -m “some great message” [master 600f084] some great message 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.rstpragmatic guide to git by travis swicegood some rights reserved
  45. 45. Creating a Commit prompt> git commit -m “some great message” [master 600f084] some great message 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.rstpragmatic guide to git by travis swicegood some rights reserved
  46. 46. Creating a Commit prompt> git commit -m “some great message” [master 600f084] some great message 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.rstpragmatic guide to git by travis swicegood some rights reserved
  47. 47. Creating a Commit prompt> git commit -m “some great message” [master 600f084] some great message 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.rst … or use the editor … prompt> git commitpragmatic guide to git by travis swicegood some rights reserved
  48. 48. Git’s Editor? GIT_EDITOR <-- environment var core.editor <-- set with git config --global VISUAL <-- environment var EDITOR <-- environment var vi <-- when all else failspragmatic guide to git by travis swicegood some rights reserved
  49. 49. Staging Changes (Part II)pragmatic guide to git by travis swicegood some rights reserved
  50. 50. Adding an Existing File prompt> git add README.rst prompt> git status # On branch master # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # modified file: README.rstpragmatic guide to git by travis swicegood some rights reserved
  51. 51. Commit Existing File prompt> git commit -m “great message” README.rst [master 3dc20b0] great message 1 files changed, 1 insertions(+), 0 deletions(-)pragmatic guide to git by travis swicegood some rights reserved
  52. 52. Commit All Changes prompt> git commit -m “great message” -a [master be1b8dc] great message 1 files changed, 1 insertions(+), 0 deletions(-)pragmatic guide to git by travis swicegood some rights reserved
  53. 53. Adding Part of a File prompt> git add -p README.rst … editor launches …pragmatic guide to git by travis swicegood some rights reserved
  54. 54. Undoing Staged Changespragmatic guide to git by travis swicegood some rights reserved
  55. 55. Remove a Staged Change prompt> git reset HEAD README.rst M README.rstpragmatic guide to git by travis swicegood some rights reserved
  56. 56. Moving Filespragmatic guide to git by travis swicegood some rights reserved
  57. 57. Moving a File prompt> git mv README.rst README.txt prompt> git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: README.rst -> README.txtpragmatic guide to git by travis swicegood some rights reserved
  58. 58. Deleting Filespragmatic guide to git by travis swicegood some rights reserved
  59. 59. Deleting a File prompt> git rm README.txt rm README.txt prompt> git status # On branch master … # deleted: README.txtpragmatic guide to git by travis swicegood some rights reserved
  60. 60. Sharing Changespragmatic guide to git by travis swicegood some rights reserved
  61. 61. Sharing Changes (from 30,000 feet)pragmatic guide to git by travis swicegood some rights reserved
  62. 62. Sending Your Changes prompt> git push <remote> [<branch>] … example … prompt> git push origin masterpragmatic guide to git by travis swicegood some rights reserved
  63. 63. Sending Your Changes prompt> git push <remote> [<branch>] … example … prompt> git push origin masterpragmatic guide to git by travis swicegood some rights reserved
  64. 64. Grabbing Other’s Changes prompt> git pull <remote> [<branch>] … example … prompt> git pull tswicegood masterpragmatic guide to git by travis swicegood some rights reserved
  65. 65. Told ya… 30,000’pragmatic guide to git by travis swicegood some rights reserved
  66. 66. Branchespragmatic guide to git by travis swicegood some rights reserved
  67. 67. What’s a Branch?pragmatic guide to git by travis swicegood some rights reserved
  68. 68. Viewingpragmatic guide to git by travis swicegood some rights reserved
  69. 69. Viewing Branches prompt> git branch * masterpragmatic guide to git by travis swicegood some rights reserved
  70. 70. Creatingpragmatic guide to git by travis swicegood some rights reserved
  71. 71. Creating a New Branch prompt> git branch <new branch> [<existing>] … example … prompt> git branch new-branch prompt> git branch * master new-branchpragmatic guide to git by travis swicegood some rights reserved
  72. 72. Switchingpragmatic guide to git by travis swicegood some rights reserved
  73. 73. Switching Branches prompt> git checkout new-branch Switched to branch new-branch prompt> git branch master * new-branchpragmatic guide to git by travis swicegood some rights reserved
  74. 74. Create & Switchpragmatic guide to git by travis swicegood some rights reserved
  75. 75. Switching Branches prompt> git checkout -b newest-branch Switched to branch newest-branch prompt> git branch master new-branch * newest-branchpragmatic guide to git by travis swicegood some rights reserved
  76. 76. Mergingpragmatic guide to git by travis swicegood some rights reserved
  77. 77. Merging Branches prompt> git checkout master Switched to branch master prompt> git merge newest-branch Updating 94f1967..a053b49 Fast-forward 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 foopragmatic guide to git by travis swicegood some rights reserved
  78. 78. Merging Branches prompt> git checkout master Switched to branch master prompt> git merge newest-branch Updating 94f1967..a053b49 Fast-forward 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 foopragmatic guide to git by travis swicegood some rights reserved
  79. 79. Fast Forward newest-branch masterpragmatic guide to git by travis swicegood some rights reserved
  80. 80. Fast Forward newest-branch masterpragmatic guide to git by travis swicegood some rights reserved
  81. 81. Merging Branches prompt> git merge new-branch Merge made by recursive. 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 barpragmatic guide to git by travis swicegood some rights reserved
  82. 82. Merging Branches prompt> git merge new-branch Merge made by recursive. 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 barpragmatic guide to git by travis swicegood some rights reserved
  83. 83. Recursive Merge new-branch masterpragmatic guide to git by travis swicegood some rights reserved
  84. 84. Recursive Merge new-branch masterpragmatic guide to git by travis swicegood some rights reserved
  85. 85. Rebasingpragmatic guide to git by travis swicegood some rights reserved
  86. 86. Rebasing Branches prompt> git checkout new-branch Switched to branch new-branch prompt> git rebase master First, rewinding head to replay your work on top of it... Applying: …pragmatic guide to git by travis swicegood some rights reserved
  87. 87. Before Rebasing new-branch masterpragmatic guide to git by travis swicegood some rights reserved
  88. 88. After Rebasing new-branch masterpragmatic guide to git by travis swicegood some rights reserved
  89. 89. Rebasing Branches prompt> git checkout new-branch Switched to branch new-branch prompt> git rebase master First, rewinding head to replay your work on top of it... Applying: …pragmatic guide to git by travis swicegood some rights reserved
  90. 90. Rebasing Branches prompt> git checkout new-branch Switched to branch new-branch prompt> git rebase 1a3cdc2 First, rewinding head to replay your work on top of it... Applying: …pragmatic guide to git by travis swicegood some rights reserved
  91. 91. Deletingpragmatic guide to git by travis swicegood some rights reserved
  92. 92. Deleting Branches prompt> git branch -d newest-branch Deleted branch newest-branch (was a053b49).pragmatic guide to git by travis swicegood some rights reserved
  93. 93. Not in Current Branch new-branch masterpragmatic guide to git by travis swicegood some rights reserved
  94. 94. Really Deleting Branches prompt> git branch -D new-branch Deleted branch new-branch (was 1a3cdc2).pragmatic guide to git by travis swicegood some rights reserved
  95. 95. Really Deleting Branches prompt> git branch -D new-branch Deleted branch new-branch (was 1a3cdc2).pragmatic guide to git by travis swicegood some rights reserved
  96. 96. Team Workpragmatic guide to git by travis swicegood some rights reserved
  97. 97. Remote Repositorypragmatic guide to git by travis swicegood some rights reserved
  98. 98. Remotespragmatic guide to git by travis swicegood some rights reserved
  99. 99. Viewing Remotes prompt> git remote prompt>pragmatic guide to git by travis swicegood some rights reserved
  100. 100. Viewing Remotes prompt> cd /usr/local prompt> git remote homebrew roder tswicegoodpragmatic guide to git by travis swicegood some rights reserved
  101. 101. Addingpragmatic guide to git by travis swicegood some rights reserved
  102. 102. Adding Remotes prompt> git remote add <remote> <url> … example … prompt> git remote add tswicegood git://github.com/tswicegood/homebrew.git prompt> git remote tswicegoodpragmatic guide to git by travis swicegood some rights reserved
  103. 103. Removingpragmatic guide to git by travis swicegood some rights reserved
  104. 104. Removing Remotes prompt> git remote rm <remote> … example … prompt> git remote rm tswicegoodpragmatic guide to git by travis swicegood some rights reserved
  105. 105. Fetchingpragmatic guide to git by travis swicegood some rights reserved
  106. 106. Fetching Changes prompt> git fetch <remote> … example … prompt> git fetch tswicegood remote: Counting objects: 3, done. … clipped … * [new branch] master -> tswicegood/masterpragmatic guide to git by travis swicegood some rights reserved
  107. 107. Remote Branchespragmatic guide to git by travis swicegood some rights reserved
  108. 108. Remote Branches prompt> git branch -r tswicegood/master … or everything at once … prompt> git branch -a * master remotes/tswicegood/masterpragmatic guide to git by travis swicegood some rights reserved
  109. 109. You Still Have to Mergepragmatic guide to git by travis swicegood some rights reserved
  110. 110. Pullingpragmatic guide to git by travis swicegood some rights reserved
  111. 111. Pulling Changes prompt> git pull <remote> <branch> … example … prompt> git pull tswicegood master … clipped … * branch master -> FETCH_HEAD Fast-forward … clipped …pragmatic guide to git by travis swicegood some rights reserved
  112. 112. Grokking Refspecs prompt> git pull <remote> <branch> … example … prompt> git pull tswicegood master … clipped … * branch master -> FETCH_HEAD Fast-forward … clipped …pragmatic guide to git by travis swicegood some rights reserved
  113. 113. Grokking Pull Refspecs prompt> git pull <remote> <remote branch>:<local branch> … examples … prompt> git pull tswicegood master prompt> git pull tswicegood master:master prompt> git pull tswicegood dev:my-devpragmatic guide to git by travis swicegood some rights reserved
  114. 114. Pulling Part 2pragmatic guide to git by travis swicegood some rights reserved
  115. 115. Pulling Changes prompt> git pull --rebase <remote> <branch> … example … prompt> git pull --rebase tswicegood master … clipped … * branch master -> FETCH_HEAD First, rewinding head to replay your work on top of it... clipped …pragmatic guide to git by travis swicegood some rights reserved
  116. 116. Pushingpragmatic guide to git by travis swicegood some rights reserved
  117. 117. Pushing Changes prompt> git push <remote> <branch> … example … prompt> git push tswicegood master … clipped … * [new branch] new-branch -> new-branchpragmatic guide to git by travis swicegood some rights reserved
  118. 118. Grokking Push Refspecs prompt> git push <remote> <local branch>:<remote branch> … examples … prompt> git push tswicegood master prompt> git push tswicegood master:master prompt> git push tswicegood my-dev:devpragmatic guide to git by travis swicegood some rights reserved
  119. 119. Team Workflowpragmatic guide to git by travis swicegood some rights reserved
  120. 120. Fully Distributed Designer Bob Developer Jane Youpragmatic guide to git by travis swicegood some rights reserved
  121. 121. Fully Distributed Designer Bob Developer Jane Youpragmatic guide to git by travis swicegood some rights reserved
  122. 122. Shared Model Designer Bob You Developer Janepragmatic guide to git by travis swicegood some rights reserved
  123. 123. Lots Morepragmatic guide to git by travis swicegood some rights reserved
  124. 124. Several Bookspragmatic guide to git by travis swicegood some rights reserved
  125. 125. PragProg.compragmatic guide to git by travis swicegood some rights reserved
  126. 126. git-scm.com #git (freenode)pragmatic guide to git by travis swicegood some rights reserved
  127. 127. Travis Swicegood travisswicegood.com @tswicegood travis@domain51.com http://joind.in/2855pragmatic guide to git by travis swicegood some rights reserved

×