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

Git - Intro and Theory

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Git - Intro and Theory

Slides for introduction to Git. Explaining: how a personal repo is designed, how branches are designed, and how the Git mindset is different from the SVN mindset.

Alex Berg

June 13, 2012

Transcript

31 slides
  1. ©2011 Sundog | www.sundoginteractive.com History • Roots in Linux –

    Written by Linus Torvalds • Motivation – BitKeeper changed license • Create new VCS, learned from BitKeeper • Keep distributed flow • Strong safeguards against corruption • High-performance • Written April 3-7, 2005
  2. ©2011 Sundog | www.sundoginteractive.com Technology • Rough Overview: • Self-sufficient

    repository • Lightweight branches • Undo-able • Very popular
  3. ©2011 Sundog | www.sundoginteractive.com Technology • Git Directory • The

    repository • Important ones • Objects = history. • Refs = pointers • Index = tracked files • HEAD = current branch
  4. ©2011 Sundog | www.sundoginteractive.com Technology • Chained Commits • Commit

    has 0, 1, or 2 parents • Each commit is a directory snapshot
  5. ©2011 Sundog | www.sundoginteractive.com Technology • Changing Branches • HEAD

    = pointer to branch pointer • To change branches, just move HEAD pointer
  6. ©2011 Sundog | www.sundoginteractive.com Technology • Branches Diverge • Checkout

    testing, commit, checkout master, commit. • It’s all the same!
  7. ©2011 Sundog | www.sundoginteractive.com Technology • Merging • Calculates, applies

    patches • ‘Merge Commit’ is commit with two parents
  8. ©2011 Sundog | www.sundoginteractive.com Technology • Merge Conflict • Pauses

    merge, asks user to manually merge • Re-stage to mark as resolved
  9. ©2011 Sundog | www.sundoginteractive.com Technology • Remotes • Remote repository

    • Remote branch is indicator only • Used for basing work on
  10. ©2011 Sundog | www.sundoginteractive.com Technology • Multiple Remotes • Multiple

    pointers • Fetch commits chain • use to merge changes • base for new branches
  11. ©2011 Sundog | www.sundoginteractive.com Practical Use • Basic commit process

    • git init (create README file) • git add README • git commit –m ‘Commit message.’
  12. ©2011 Sundog | www.sundoginteractive.com Practical Use • Basic branch process

    • git branch featureA • git checkout featureA (make changes/additions) • git add (files) • git commit –m ‘Add feature A’
  13. ©2011 Sundog | www.sundoginteractive.com Practical Use • Basic merge process

    • git checkout master (make changes/additions) • git commit –a –m ‘Add feature A’ • git merge featureA • git branch –d featureA
  14. ©2011 Sundog | www.sundoginteractive.com CLI Example 1 • Try committing

    • Create repo • Commit directory to repo • Create a file, modify a file, commit them
  15. ©2011 Sundog | www.sundoginteractive.com CLI Example 2 • Try Branching

    • Work on experimental feature. Use a branch • Merge experimental feature back to master
  16. ©2011 Sundog | www.sundoginteractive.com CLI Example 3 • Try cloning

    • Add remote repository • Clone it into local repo • Branch, develop, and push to remote
  17. ©2011 Sundog | www.sundoginteractive.com GitHub Example 1 • Try cloning

    • Add remote repository • Clone it into local repo • Branch, develop, and push to remote
  18. ©2011 Sundog | www.sundoginteractive.com Practical Use • Common Commands •

    git status • git add [file] • git commit • git diff (--staged) • Destructive Commands • git reset [file] • git rm [file]

More Decks by Alex Berg

Other Decks in Programming