git going with dvcs v1.5.2

167
by Matthew McCullough of Ambient Ideas, LLC with DVCS Git going 50 minutes of mental spoon bending via source code control

Upload: matthew-mccullough

Post on 10-May-2015

2.755 views

Category:

Education


5 download

DESCRIPTION

Git presentation to the Utah Java Users Group (UJUG)

TRANSCRIPT

Page 1: Git Going With DVCS v1.5.2

by Matthew McCullough of Ambient Ideas, LLC

with DVCSGit going

50 minutes of mental spoon bending

via source code control

Page 2: Git Going With DVCS v1.5.2

DVCS

What? Why?

Basic Use

Who? GUI

Theory

Sharing

Interop High Points

Page 3: Git Going With DVCS v1.5.2

Git-nounBritish Slang. an unpleasant or

contemptible person

-Oxford English Dictionary

Page 4: Git Going With DVCS v1.5.2

Page 5: Git Going With DVCS v1.5.2
Page 7: Git Going With DVCS v1.5.2

CVS

BitKeeperSubversion

PVCS

Perforce

ClearCaseSource

Safe

Mercurial

Bazaar

RCS

Folders

darcs

Page 8: Git Going With DVCS v1.5.2

GitSource Code Control

Page 9: Git Going With DVCS v1.5.2

CultureChange

Page 10: Git Going With DVCS v1.5.2
Page 11: Git Going With DVCS v1.5.2
Page 12: Git Going With DVCS v1.5.2
Page 13: Git Going With DVCS v1.5.2

CentralizedVCS =Don’t

Page 14: Git Going With DVCS v1.5.2

DoWhatever!DistributedVCS =

Page 15: Git Going With DVCS v1.5.2

InnovateExperiment

Safely Be WrongDrive-by AssistCrowd Source

Page 16: Git Going With DVCS v1.5.2

Crowd Source

Page 17: Git Going With DVCS v1.5.2
Page 18: Git Going With DVCS v1.5.2

① Download binaries

Page 19: Git Going With DVCS v1.5.2

Win Cygwin

Win msysGit

Linux Source

Linux Package manager

Mac MacPorts

Mac git-osx-installer

Any JGit

Git Distro Sources

Page 20: Git Going With DVCS v1.5.2

② Put it in your path

Page 21: Git Going With DVCS v1.5.2
Page 22: Git Going With DVCS v1.5.2

③ Identify yourself

Page 23: Git Going With DVCS v1.5.2

git config --global user.name "Hal Smith"

git config --global user.email "[email protected]"

Global Git Settings

Page 24: Git Going With DVCS v1.5.2

④ Use it!

Page 25: Git Going With DVCS v1.5.2

mkdir myproj.git

cd myproj.git

git init

Creating a Repo

Page 26: Git Going With DVCS v1.5.2

Just show it to me!

Page 27: Git Going With DVCS v1.5.2
Page 28: Git Going With DVCS v1.5.2
Page 29: Git Going With DVCS v1.5.2

CertifiedGit User

Page 30: Git Going With DVCS v1.5.2
Page 31: Git Going With DVCS v1.5.2

145+ Commands

Page 32: Git Going With DVCS v1.5.2

Follow theDOTS

Page 33: Git Going With DVCS v1.5.2

Symmetric

Page 34: Git Going With DVCS v1.5.2

subversion server

developer A developer B

Page 35: Git Going With DVCS v1.5.2

chec

k in

Page 36: Git Going With DVCS v1.5.2

update

Page 37: Git Going With DVCS v1.5.2
Page 38: Git Going With DVCS v1.5.2

check in

Page 39: Git Going With DVCS v1.5.2

upda

te

Page 40: Git Going With DVCS v1.5.2
Page 41: Git Going With DVCS v1.5.2

Symmetric

Page 42: Git Going With DVCS v1.5.2

Distributed

Page 43: Git Going With DVCS v1.5.2

developer A developer B

Page 44: Git Going With DVCS v1.5.2

blessed repo

developer A developer B

Page 45: Git Going With DVCS v1.5.2

commitcommitcommit

commitcommit

commit commit

Page 46: Git Going With DVCS v1.5.2

delete delete

Page 47: Git Going With DVCS v1.5.2

rebase

Page 48: Git Going With DVCS v1.5.2

push

Page 49: Git Going With DVCS v1.5.2

push

Page 50: Git Going With DVCS v1.5.2

push

Page 51: Git Going With DVCS v1.5.2

push

Page 52: Git Going With DVCS v1.5.2

pull

Page 53: Git Going With DVCS v1.5.2

pull

Page 54: Git Going With DVCS v1.5.2

Distributed

Page 55: Git Going With DVCS v1.5.2

WorkingOffline

Page 56: Git Going With DVCS v1.5.2
Page 57: Git Going With DVCS v1.5.2

More available connectivity

Page 58: Git Going With DVCS v1.5.2
Page 59: Git Going With DVCS v1.5.2

More demand to work without connectivity

Page 60: Git Going With DVCS v1.5.2

CheckinAddBranchList change logGrep historyRewrite historyStashMergeLabelRemovepractically everything but push

Offline Anything

Page 61: Git Going With DVCS v1.5.2

Cool! Another commit to my latest OSS

project using Git!

I liked subversion better...

Page 62: Git Going With DVCS v1.5.2

DVCS

What? Why?

Basic Use

Who? GUIs

Theory

Sharing

Interop High Points

Page 63: Git Going With DVCS v1.5.2

Who’s Got Git?

Page 64: Git Going With DVCS v1.5.2
Page 65: Git Going With DVCS v1.5.2
Page 66: Git Going With DVCS v1.5.2
Page 67: Git Going With DVCS v1.5.2
Page 68: Git Going With DVCS v1.5.2
Page 69: Git Going With DVCS v1.5.2

GUIs

Page 70: Git Going With DVCS v1.5.2

GitX

Page 71: Git Going With DVCS v1.5.2

GitSafe

Page 72: Git Going With DVCS v1.5.2

GitK

Page 73: Git Going With DVCS v1.5.2

GitGUI

Page 74: Git Going With DVCS v1.5.2

EGit

Page 75: Git Going With DVCS v1.5.2
Page 76: Git Going With DVCS v1.5.2

It’s Officia

l!

Page 77: Git Going With DVCS v1.5.2

UsageModels

Page 78: Git Going With DVCS v1.5.2

Central Repo

Ce

nt

ra

liz

ed

Page 79: Git Going With DVCS v1.5.2

Blessed Repo

Dic

ta

to

rs

hip

Page 80: Git Going With DVCS v1.5.2

Certified Repo

Development Repo

Int

eg

ra

tio

n M

an

ag

ed

Page 81: Git Going With DVCS v1.5.2

Mirror

Development Repo

Mir

ro

re

d

Mirror

Certified Repo

Page 82: Git Going With DVCS v1.5.2

Cu

st

om

+ P

ub

lic

Co

nt

rib

Customized

☚ P

riva

te

Pub

lic ☛

GitHub

Page 83: Git Going With DVCS v1.5.2

Hashes and Git

Page 84: Git Going With DVCS v1.5.2

‣Centralized VCS uses DB sequential index.

Index vs Hash

Page 85: Git Going With DVCS v1.5.2

‣Git uses SHA-1 hash.

Index vs Hash

Page 86: Git Going With DVCS v1.5.2

I thought

hashes were

for

passwords?

Page 87: Git Going With DVCS v1.5.2

‣ Different goals.‣ Hash for the sake of integrity.‣ Hash for the sake of identity.

SHA-1 Hash

Page 88: Git Going With DVCS v1.5.2

40 hex characters

Page 89: Git Going With DVCS v1.5.2

Use as little of it as is unique

Page 90: Git Going With DVCS v1.5.2

Treeish

Page 91: Git Going With DVCS v1.5.2

Shorthand for the hashes

Page 92: Git Going With DVCS v1.5.2

9AB223

Page 93: Git Going With DVCS v1.5.2

9AB223^

Page 94: Git Going With DVCS v1.5.2

9AB223..56CD77

Page 95: Git Going With DVCS v1.5.2

HEAD

Page 96: Git Going With DVCS v1.5.2

HEAD^

Page 97: Git Going With DVCS v1.5.2

HEAD~3

Page 98: Git Going With DVCS v1.5.2

But I’ve been

hearing news

about hash

collisions...

Page 99: Git Going With DVCS v1.5.2

earth atoms10

49

Page 100: Git Going With DVCS v1.5.2

SHA11046

Page 101: Git Going With DVCS v1.5.2

stars10

22

Page 102: Git Going With DVCS v1.5.2

sand grains10

20

Page 103: Git Going With DVCS v1.5.2

collision10

19

Page 104: Git Going With DVCS v1.5.2

‣Blob‣Tree‣Commit‣Tag

Hashable Objects

Page 105: Git Going With DVCS v1.5.2

http://book.git-scm.com/1_the_git_object_model.html

Page 106: Git Going With DVCS v1.5.2

Integrity‣ Identifies damaged repos.‣ Prevents modification of published history.‣ Unique to file size and contents.

Hash Benefits

Page 107: Git Going With DVCS v1.5.2

Tags‣ Cryptographically sign tags by GPG.‣ Guarantee repo’s state at a point in time.

Hash Benefits

Page 108: Git Going With DVCS v1.5.2

Storage Mechanics

Page 109: Git Going With DVCS v1.5.2

Typical SCMs use delta storage

Page 110: Git Going With DVCS v1.5.2

CVS / Subversion / darcs / Mercurial

Page 111: Git Going With DVCS v1.5.2

Checkin

Checkin Checkin Che

ckin

Che

ckin

Che

ckin

Che

ckin

Che

ckin

Check

in

Checkin

Checkin

Delta storage gets slower as the history of a file gets longer

Page 112: Git Going With DVCS v1.5.2

Git uses DAG storage

Page 113: Git Going With DVCS v1.5.2

Directed Acyclic Graph

Page 114: Git Going With DVCS v1.5.2

Copy of the entire tree per checkin

Page 115: Git Going With DVCS v1.5.2

cp -r srcfolder srcfolder.prev

Page 116: Git Going With DVCS v1.5.2
Page 117: Git Going With DVCS v1.5.2

Sounds inefficient...

Page 118: Git Going With DVCS v1.5.2

zlib deflates every blob at commit

Page 119: Git Going With DVCS v1.5.2

I’ve had a

400MB Subversion repo

convert to a 70MB Git repo

Page 120: Git Going With DVCS v1.5.2

Speed

Page 121: Git Going With DVCS v1.5.2

git: git

hg: mercurial

bzr: bazaar

Page 122: Git Going With DVCS v1.5.2

data from http://whygitisbetterthanx.com/#git-is-fast

git hg bzr

Init

git hg bzr

Add

git hg bzr

Status

git hg bzr

Diff

git hg bzr

Tag

git hg bzr

Log

git hg bzr

Commit (Lg)

git hg bzr

Commit (Sm)

git c git h hg c hg h bzr c bzr h

Branch (Cold/Hot)

Page 123: Git Going With DVCS v1.5.2

bazaar numbers plus network latency

subversion =

Page 124: Git Going With DVCS v1.5.2

to100 timesFaster

10

Page 125: Git Going With DVCS v1.5.2

Location,Location,Location

Page 126: Git Going With DVCS v1.5.2

Three Stage Thinkingof Git

Page 127: Git Going With DVCS v1.5.2

Git‣ git add‣ git commit‣ git push

Page 128: Git Going With DVCS v1.5.2

‣ Commits only what is added to the index.‣ Opportunity to rewrite history locally.‣ Provides time to change your mind.‣ Selectively share with other repos.

Page 129: Git Going With DVCS v1.5.2

Git‣ git stash‣ git stash apply

Page 130: Git Going With DVCS v1.5.2

‣ Save work-in-progress temporarily, but safely.

‣ Merge stashed modifications back in.

Page 131: Git Going With DVCS v1.5.2

Repo

is like a special

IndexWorking

Stash

git clone

git checkout

edit experiment files

git stash

test buggy files

git stash apply

git add

git commit

Rem

ote

git push

Page 132: Git Going With DVCS v1.5.2

git clone git://somedomain/myproj.gitcd myproj.git

git checkout master

echo ‘//Comments’ >> ClassOne.javaecho ‘//Thoughts’ >> ClassTwo.java

git add ClassOne.javagit commit -m’Added comments’

git stash

◀Build repo

◀Update index

◀Edit working

◀Add to index

◀Save to repo

◀Push to stash

Page 133: Git Going With DVCS v1.5.2

Merge & Rebase

Page 134: Git Going With DVCS v1.5.2

git branch newbranchgit checkout -b newer remote/branchnm

Cheap Branches

Page 135: Git Going With DVCS v1.5.2

git show-branch --allgit branch -a

Cheap Branches

Page 136: Git Going With DVCS v1.5.2

‣Local branch‣localbranchname

‣Remote branch‣remote/branchname

Page 137: Git Going With DVCS v1.5.2

git merge --no-commit <sourcebranch>git merge --squash <sourcebranch>git merge <sourcebranch1> <sourcebranch2>

Merge Anything

Page 138: Git Going With DVCS v1.5.2

git checkout myfeaturebranchgit rebase master

Rebase for Clarity

Page 139: Git Going With DVCS v1.5.2

‣Fast forwards the “side” branch.‣Reposition your feature branch’s start point.

‣See “how trunk will act” before you merge.

‣Makes for simpler merge graphs.‣Cleaner history than a merge.

Rebase for Clarity

Page 140: Git Going With DVCS v1.5.2

Standard

Mergea32

2e2

e69

d19

8b3

Branch

Mas

ter/

Trun

k/M

ainL

ates

t

9f1Merg

e

Page 141: Git Going With DVCS v1.5.2

Rebasing

a32

2e2

e69

d19

8b3

Branch

Mas

ter/

Trun

k/M

ainL

ates

t

Page 142: Git Going With DVCS v1.5.2

a32

2e2

e69

d19

8b3 Branch

Mas

ter/

Trun

k/M

ainL

ates

t

Rebase

Page 143: Git Going With DVCS v1.5.2

a32

2e2

e69

d19

8b3 Branch

Mas

ter/

Trun

k/M

ainL

ates

t

e69

d19 Merge

Page 144: Git Going With DVCS v1.5.2

DVCS

What? Why?

Basic Use

Who? GUIs

Theory

Sharing

Interop High Points

Page 145: Git Going With DVCS v1.5.2

Sharing

Page 146: Git Going With DVCS v1.5.2

Protocols‣ GIT‣ SSH‣ SCP

‣ Local file system‣ SAMBA

‣ HTTP‣ WebDAV

‣ rsync

Serving It Up

Page 147: Git Going With DVCS v1.5.2

git clone git://somehost.org/myproj.git

git clone [email protected]:myproj.git

git clone http://somehost.org/myproj.git

git clone ~/work/myproj.git

git clone z:\someserver\myproj.git

◀git daemon

◀SSH

◀HTTP

◀Filesystem

◀Network drive

Page 148: Git Going With DVCS v1.5.2

‣ git instaweb. Built in, read-only, HTTP.

‣ git daemon. Custom socket language.

‣ gitosis. Easy permissions control.

‣ github. Open source & private repos.

‣ ssh. OS controlled permissions.

Serving It Up

Page 149: Git Going With DVCS v1.5.2
Page 150: Git Going With DVCS v1.5.2
Page 151: Git Going With DVCS v1.5.2

SVN Interop

Page 152: Git Going With DVCS v1.5.2

git svn clone http://unfurl.com/trunkgit svn dcommit

Subversion

Page 153: Git Going With DVCS v1.5.2

‣ First class compatibility.

‣ Round trip support.

‣ Git commits = svn commits.

Subversion

Page 154: Git Going With DVCS v1.5.2
Page 155: Git Going With DVCS v1.5.2

‣ git svn clone

Migration

Page 156: Git Going With DVCS v1.5.2

‣ Power off your Subversion server.

Migration

Page 157: Git Going With DVCS v1.5.2

reasons3

Page 158: Git Going With DVCS v1.5.2

❸‣git cherry-pick a5b2ee

‣Merge in just one commit.

Cherry Pick

Page 159: Git Going With DVCS v1.5.2

❷‣git grep SomeText HEAD^^^

‣Search blob contents history without checkouts.

Search History

Page 160: Git Going With DVCS v1.5.2

❶‣git bisect run mvn test

‣Binary-search for bug.

‣Manual or automated modes.

Bisect Bugs

Page 161: Git Going With DVCS v1.5.2
Page 162: Git Going With DVCS v1.5.2

emergingVersion Control System

Page 163: Git Going With DVCS v1.5.2

MatthewTwitter @matthewmccull

Blog http://www.ambientideas.com/blog sidebar has all my social media links

Email [email protected]

GitHub http://github.com/matthewmccullough

Page 164: Git Going With DVCS v1.5.2

Git Homepagehttp://git-scm.com

Directed Acrylic Graphhttp://en.wikipedia.org/wiki/Directed_acyclic_graph

Git for Computer Scientistshttp://eagain.net/articles/git-for-computer-scientists/

Git Treeishhttp://book.git-scm.com/4_git_treeishes.html

Resources

Page 165: Git Going With DVCS v1.5.2

Git Docshttp://www.kernel.org/pub/software/scm/git/docs/

Git Magic eBookhttp://www-cs-students.stanford.edu/~blynn/gitmagic/book.pdf

Linus Torvald’s Git talk at Googlehttp://www.youtube.com/watch?v=4XpnKHJAok8

CygWinhttp://www.cygwin.com

Resources

Page 166: Git Going With DVCS v1.5.2

MSysGithttp://code.google.com/p/msysgit

Git Cheetahhttp://code.google.com/p/msysgit/wiki/GitCheetah

Matthew’s Git Bookmarkshttp://delicious.com/matthew.mccullough/git

Matthew’s Bash Prompthttp://gist.github.com/47267

Resources

Page 167: Git Going With DVCS v1.5.2

‣ http://www.ambientideasphotography.com‣ http://flickr.com/photos/lenore-m/2903856664/‣ http://en.wikipedia.org/wiki/Git_(software)‣ http://flickr.com/photos/karenhorton/1583513014/‣ http://flickr.com/photos/mashdnart/2545782407/‣ http://commons.wikimedia.org/wiki/

File:Small_Boy_nuclear_test_1962.jpg‣ http://www.flickr.com/photos/knmurphy/2506896257/‣ http://www.flickr.com/photos/albyspace/1022035568/‣ http://flickr.com/photos/michaelhays/3070238360/‣ http://flickr.com/photos/d_vdm/509996632/

Image Credits