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

Git: An Illustrated Primer

Git: An Illustrated Primer

Given at the July BCSPHP Meeting

Daniel Cousineau

July 18, 2012
Tweet

More Decks by Daniel Cousineau

Other Decks in Programming

Transcript

  1. 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...”
  2. +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!"
  3. +Linux Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    $> sudo apt-get install git $> sudo yum install git $> echo "Seriously?"
  4. +Doing as I am told Daniel Cousineau // follow me

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

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

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

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

    me : @dcousineau or http://dcousineau.com
  9. +See Our New Branch Daniel Cousineau // follow me :

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

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

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

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

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

    me : @dcousineau or http://dcousineau.com
  15. +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
  16. +Sync Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com

    $> git svn dcommit --dry-run $> git svn dcommit $> git svn rebase
  17. +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
  18. +Local Branching Daniel Cousineau // follow me : @dcousineau or

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

    merge --squash localbrn HEAD a b c MASTER localbrn d e
  20. +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
  21. +tracking svn branches Daniel Cousineau // follow me : @dcousineau

    or http://dcousineau.com $> git checkout -t remotes/branchname
  22. +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
  23. +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
  24. 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
  25. 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
  26. +reset my local changes Daniel Cousineau // follow me :

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

    or http://dcousineau.com $> git reset --mixed REF
  28. +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.
  29. +“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
  30. +“Oops i forgot to branch” Daniel Cousineau // follow me

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

    : @dcousineau or http://dcousineau.com
  32. +“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
  33. +Lay of the land Daniel Cousineau // follow me :

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

    @dcousineau or http://dcousineau.com
  35. +“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 ಠ_ಠ
  36. +gone now, here yesterday Daniel Cousineau // follow me :

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

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

    @dcousineau or http://dcousineau.com
  39. +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