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.

Grokking Git with Shakespeare

419 views

Published on

A talk on git basics, diffing, merging and rebasing.

Published in: Software
  • The accompanying demo script is here: http://www.slideshare.net/james-world/windows-demo-script-to-accompany-grokking-git-with-shakespeare
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Grokking Git with Shakespeare

  1. 1. “To merge or to rebase, that is the question.” HAMLET Grokking Git with Shakespeare James World – Brighton .NET User Group Sep 2015
  2. 2. “All the world’s a staging area, and all the commits merely players…” AS YOU LIKE IT staging area cache index commit ref branch working tree file system
  3. 3. Repository git checkout
  4. 4. Repository git add
  5. 5. Repository git commit
  6. 6. commit objects tree objects blob objects HEAD
  7. 7. master HEAD feature1
  8. 8. master HEAD feature1 feature2 feature2 HEAD^^2 master~1^2 feature1~2 “A branch, by any other name would smell as sweet.” ROMEO AND JULIET
  9. 9. “Two branches, both alike in dignity.” ROMEO AND JULIET A X Y master feature1 feature2
  10. 10. “I have merged, and seen the spider.” A WINTER’S TALE A X Yfeature1 feature2 Bxmaster git merge --no-ff feature1
  11. 11. “Jog on, jog on, the fast forward way.” A WINTER’S TALE A X Y feature1 feature2master git merge feature1
  12. 12. “Oh, how this spring of log resembleth… And by and by a double dot takes all away” THE TWO GENTLEMEN OF VERONA A BA B A B git log A..B
  13. 13. “Thou mis-shapen dick!” HENRY VI git log A...B A BA B A B
  14. 14. “We know what we are, but know not what diff we may be.” HAMLET git diff A..B git diff A...B A B A B SAME AS A B
  15. 15. “I see how thine merge would emulate a diamond.” THE MERRY WIVES OF WINDSOR A X Y feature2 Bxymaster git merge feature2
  16. 16. “Rebasing hath made thee a tame snake.” AS YOU LIKE IT A X Y feature1 feature2 master Y A Xfeature1 feature2master Y git rebase master [feature2] git merge feature2
  17. 17. “What’s done can be reverted.” MACBETH A Xfeature1 feature2 Y Xmaster
  18. 18. “Git thee to a repository.” HAMLET GET HELP: git help <command name> ADD AN ALIAS: git config --global --add alias.lg “log --oneline --decorate --all --graph” SEE A DIFF: git diff [<from commit>] <to commit> MERGE INTO A BRANCH: git checkout <branch to merge into> git merge <branch to merge> REBASE A BRANCH: git rebase <new base> [<branch to rebase>] UNDO YOUR MISTAKES: git reflog git reset --hard <commit> (escape { with backtick in powershell: git reset –hard @HEAD`{1`}) THESE ARE MORE INTERESTING THAN USEFUL: git hash-object <file> git cat-file –p <sha>
  19. 19. @jamesw0rld

×