Git: An Illustrated Primer

Git: An Illustrated Primer

Given at the July BCSPHP Meeting

6696617169722009ed1ec8c52496c6da?s=128

Daniel Cousineau

July 18, 2012
Tweet

Transcript

  1. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com GIT:

    An Illustrated Primer
  2. http://mojolive.com/profile/dcousineau Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  3. History Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  4. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com BitKeeper

    No Longer Free To Use Linux Kernel Requires Distributed Performant SVN and CVS... Not So Much “CVS is what we should NOT do...”
  5. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com GIT

    thus,
  6. gItting started Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  7. +OSX Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    http://git-scm.com
  8. +OSX Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    $> /usr/bin/ruby -e \ "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" $> brew install git $> say "Win!"
  9. +Linux Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    $> sudo apt-get install git $> sudo yum install git $> echo "Seriously?"
  10. +Windows Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    http://windows.github.com
  11. +My First Repo Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  12. +Stage New Files Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  13. +Commit Staging Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  14. +staging? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    working directory index repository
  15. +staging? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    working directory index repository “staging”
  16. +staging? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    working directory index repository modify
  17. +staging? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    working directory index repository git add
  18. +staging? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    working directory index repository git commit
  19. +Directories Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  20. +Modify Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  21. +Branch! Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  22. +Back to Master Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  23. +Merge! Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  24. +stashing Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  25. +Popping Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  26. branching Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  27. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com a

    b c MASTER HEAD
  28. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com a

    b c MASTER DEVELOP create new branch HEAD
  29. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com a

    b c MASTER DEVELOP Checkout new branch HEAD
  30. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com a

    b c MASTER DEVELOP commit to develop d HEAD
  31. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com commit

    to master HEAD a b c MASTER DEVELOP d e
  32. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com a

    b c MASTER DEVELOP merge Develop d e f
  33. Remote Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  34. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com SVN

    GIT d e b a c d e b a c d d e b a c
  35. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  36. +Create a Project Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  37. +Create a Project Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  38. +Doing as I am told Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  39. +did as I was told Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  40. +Push Again! Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  41. +Fetching & Merging Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  42. +Pulling Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  43. +Two Authors Two Pushes Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  44. +Two Authors Two Pushes Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  45. +AFtermath Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  46. +Aftermath Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  47. +Aftermath Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  48. +AFtermath Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  49. +forking Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  50. +pull requests Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  51. +MAke Changes IN A NEW BRANCH Daniel Cousineau // follow

    me : @dcousineau or http://dcousineau.com
  52. +Push Changes Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  53. +See Our New Branch Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  54. +Create Pull Request Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  55. +Oh Look, Our Pull Request Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  56. +Oh Look Our Pull Request Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  57. +Oh Look, It’s Merged In! Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  58. +Remotes Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  59. +Adding Another Remote Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  60. +create and sync new branches Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  61. +Delete local and remote branches Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  62. +Pull From One, Push To Another Daniel Cousineau // follow

    me : @dcousineau or http://dcousineau.com
  63. GIT FLow Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  64. http://nvie.com/posts/a-successful-git-branching-model/

  65. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  66. Subversion and GIT Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  67. +et voilà Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com $> git svn clone -s -r 1000:HEAD https://url/to/repo ./wkngcpy $> git svn show-ignore > .gitignore
  68. +Workflow Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    Normal GIT Workflow
  69. +Sync Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    $> git svn dcommit --dry-run $> git svn dcommit $> git svn rebase
  70. +With some caveats Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com anything that has been dcommit’d is set in stone! do. not. touch. git branches well svn... not so much
  71. +Local Branching Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com $> git merge --squash branch
  72. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com git

    merge --squash localbrn HEAD a b c MASTER localbrn d e
  73. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com git

    merge --squash localbrn HEAD a b MASTER DEC
  74. +Why? Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    SVN is TERRIBLE at merges git-svn will do it if you don’t and when it fails, it does so spectacularly you’ll just litter your commit history
  75. +tracking svn branches Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com $> git checkout -t remotes/branchname
  76. +creating remote branches Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com $> git svn branch -m “Creating new branch” branchname $> git checkout -t remotes/branchname
  77. +personal opinion Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com except for release tagging and a develop branch don’t bother with remote branching just stick to local and squashes
  78. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com use

    git svn locally push for team adoption procure git server full clone push to new git server
  79. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com use

    git svn locally push for team adoption procure git server full clone push to new git server
  80. Advanced Usage Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  81. +reset my local changes Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com $> git checkout -- . tell git “no more options!”
  82. +Replay Last commit Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com $> git reset --mixed REF
  83. +Gitting Ready Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  84. +Results Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  85. +Undo Last commit Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com $> git reset --hard HEAD^ HEAD^ means commit prior to HEAD. HEAD^2 is 2 commits prior, etc etc.
  86. +“Oops i forgot to branch” Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com $> git branch newbranchname $> git reset --hard SHA commit immediately before the intended first commit of our new branch
  87. +“Oops i forgot to branch” Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  88. +“Oops i forgot to branch” Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  89. +“Oops I accidentally the commit message” Daniel Cousineau // follow

    me : @dcousineau or http://dcousineau.com $> git rebase --interactive SHA commit immediately preceding the commit in question
  90. +Oops Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  91. +Lay of the land Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  92. +Making decisions Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  93. +Reach 88MPH Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  94. +Fun with Paradoxes Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  95. +Fruits of our labor Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  96. +“Oops I committed the private key” Daniel Cousineau // follow

    me : @dcousineau or http://dcousineau.com $> git filter-branch --index-filter \ 'git rm --cached --ignore-unmatch secret.key' \ --prune-empty --tag-name-filter cat -- --all ಠ_ಠ
  97. +Terrible Mistake Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  98. +gone now, here yesterday Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  99. +VooDoo Magic Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com
  100. +Results Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

  101. +Cleanup The Mess Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com
  102. +Look Ma, No secret.key! Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  103. THANKS. FOR YOUR ATTENTION Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com
  104. +further resources Daniel Cousineau // follow me : @dcousineau or

    http://dcousineau.com http://git-scm.com/book FREE! Attribution-NonCommercial-ShareAlike 3.0 Unported https://help.github.com