Slide 1

Slide 1 text

Version Control With Git A tale forked merged and bludgeoned by Clint Shryock

Slide 2

Slide 2 text

A brief history

Slide 3

Slide 3 text

• 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

Slide 4

Slide 4 text

• 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

Slide 5

Slide 5 text

How Git Works

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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!

Slide 10

Slide 10 text

How Git Works Thinking About Data: Git Model • 3 states: unmodified, modified, staged • 3 sections: Git directory, working directory, staging area

Slide 11

Slide 11 text

Branching

Slide 12

Slide 12 text

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?

Slide 13

Slide 13 text

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)

Slide 14

Slide 14 text

Branching Commit disected

Slide 15

Slide 15 text

Branching A Series of Commits

Slide 16

Slide 16 text

Branching What’s a branch already

Slide 17

Slide 17 text

Branching What’s a branch already

Slide 18

Slide 18 text

Branching Special pointer: HEAD

Slide 19

Slide 19 text

Branching Special pointer: HEAD $ git branch testing

Slide 20

Slide 20 text

Branching Special pointer: HEAD $ git checkout testing

Slide 21

Slide 21 text

Branching Special pointer: HEAD $ vim test.rb $ git commit -a -m “A change”

Slide 22

Slide 22 text

Branching Special pointer: HEAD $ git checkout master

Slide 23

Slide 23 text

Branching Special pointer: HEAD $ vim test.rb $ git commit -a -m “Another change”

Slide 24

Slide 24 text

Demos!

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Collaboration

Slide 27

Slide 27 text

• Remote repositories are hosted versions of your project • Possible to have several remotes • Some push some pull Remotes Collaboration

Slide 28

Slide 28 text

• Clone • Fetch • Pull • Rebase Getting data Collaboration

Slide 29

Slide 29 text

• References to the state of branches on your remote repositories • Moved automatically whenever you fetch • origin/master origin/feature/awesome-feature Remote Branches Collaboration

Slide 30

Slide 30 text

Working with Remote Branches Collaboration

Slide 31

Slide 31 text

Working with Remote Branches Collaboration $ git clone [email protected]:project.git

Slide 32

Slide 32 text

Working with Remote Branches Collaboration

Slide 33

Slide 33 text

Working with Remote Branches Collaboration

Slide 34

Slide 34 text

Working with Remote Branches Collaboration $ git fetch origin

Slide 35

Slide 35 text

Working with Remote Branches Collaboration $ git merge origin/database

Slide 36

Slide 36 text

Git on the Server

Slide 37

Slide 37 text

• 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

Slide 38

Slide 38 text

• 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

Slide 39

Slide 39 text

• 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

Slide 40

Slide 40 text

• 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

Slide 41

Slide 41 text

• 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

Slide 42

Slide 42 text

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