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

Version Control with Git

Clint Shryock
December 05, 2011

Version Control with Git

Talk on Git from January 2011 CoMO Rich Web meet up

Clint Shryock

December 05, 2011
Tweet

More Decks by Clint Shryock

Other Decks in Technology

Transcript

  1. • Changes passed around via patches and archive files •

    Started using BitKeeper in 2002 • Things were good mostly... • Allegation of license violations • Free license revoked in 2005 • Git project was born (hurray!) Linux Kernel Maintenance A Brief History
  2. • Speed • Simple design • Strong support for non-linear

    development (thousands of parallel branches) • Fully distributed • Able to handle large projects like the Linux kernel efficiently (speed and data size) Design Goals A Brief History
  3. How Git Works Thinking About Data: SVN Model • It’s

    a series of tubes! diffs • Operations usually include network overhead • Offline support: edit but can’t commit
  4. How Git Works Thinking About Data: SVN Model • It’s

    a series of tubes! diffs • Operations usually include network overhead • Offline support: edit but can’t commit • A Sad Keanu
  5. How Git Works Thinking About Data: Git Model • A

    set of snapshots • Generally doesn’t require any network connection • Can edit commit branch merge rewind
  6. How Git Works Thinking About Data: Git Model • A

    set of snapshots • Generally doesn’t require any network connection • Can edit commit branch rewind • Happy Keanu!
  7. How Git Works Thinking About Data: Git Model • 3

    states: unmodified, modified, staged • 3 sections: Git directory, working directory, staging area
  8. Branching • SHA-1 checksum • Pointer to the snapshot •

    Author and message metadata • Zero or more pointers to direct parents First: What’s in a commit?
  9. Branching When you commit Example: Stage 3 files • Checksum

    for each file • Store that file version in the Git repository • Adds checksum to staging area Commit those files • Git checksums each subdirectory • Stores those tree objects in the Git repository • Create a commit object with metadata and pointer to the root project tree (you liked it so you put a SHA-1 on it)
  10. Demos! • add • modify • stage • commit •

    branch • merge Demos • log • log ..master log master.. • ignore • diff (--cached) • stash • merge from remote • branch from remote's fetch
  11. • Remote repositories are hosted versions of your project •

    Possible to have several remotes • Some push some pull Remotes Collaboration
  12. • References to the state of branches on your remote

    repositories • Moved automatically whenever you fetch • origin/master origin/feature/awesome-feature Remote Branches Collaboration
  13. • Remote repositories are typically bare • Several protocols to

    choose from • local /opt/git/project.git • git:// • ssh:// • http(s):// Hosting Git Repositories on the Server Git on the Server
  14. • Repository is in another directory on disk • Works

    well if your team has access to shared filesystem • direct patch vs. file:// • Pros • leverage existing file permissions and network access • can pull directly from each other, bypassing remotes • Cons • limited by network access • NFS mount can be slower than SSH on the same server Local Protocol Git on the Server
  15. • Pros • SSH is easy to setup • All

    data transfer is encrypted and authenticated • Efficient: data as compacted before transfer • Cons • Can’t serve anonymous access SSH Protocol Git on the Server
  16. • Pros • Fastest transfer protocol available • Uses same

    data-transfer mechanism as SSH protocol • Can serve anonymous access • Cons • Lack of authentication • More difficult to setup Git Protocol Git on the Server
  17. • Pros • Simplicity • Uses same data-transfer mechanism as

    SSH protocol • Can serve anonymous access • Cons • Inefficient for the client • No* write access HTTP(s) Protocol Git on the Server
  18. Version Control With Git Images that weren’t total hacks were

    used with consent courtesy of Scott Chacon http://scottchacon.com/ @ctshryock ctshryock.com github.com/ctshryock/GitTalk github.com/progit progit.org twitter www sources