git going with dvcs v1.5.2
DESCRIPTION
Git presentation to the Utah Java Users Group (UJUG)TRANSCRIPT
by Matthew McCullough of Ambient Ideas, LLC
with DVCSGit going
50 minutes of mental spoon bending
via source code control
DVCS
What? Why?
Basic Use
Who? GUI
Theory
Sharing
Interop High Points
Git-nounBritish Slang. an unpleasant or
contemptible person
-Oxford English Dictionary
“
”
≉
I'm an egotistical bastard, and
I name all my projects
after myself. First Linux,
now git.-Linus Torvalds
“
”now git.
CVS
BitKeeperSubversion
PVCS
Perforce
ClearCaseSource
Safe
Mercurial
Bazaar
RCS
Folders
darcs
GitSource Code Control
CultureChange
CentralizedVCS =Don’t
DoWhatever!DistributedVCS =
InnovateExperiment
Safely Be WrongDrive-by AssistCrowd Source
Crowd Source
① Download binaries
Win Cygwin
Win msysGit
Linux Source
Linux Package manager
Mac MacPorts
Mac git-osx-installer
Any JGit
Git Distro Sources
② Put it in your path
③ Identify yourself
git config --global user.name "Hal Smith"
git config --global user.email "[email protected]"
Global Git Settings
④ Use it!
mkdir myproj.git
cd myproj.git
git init
Creating a Repo
Just show it to me!
CertifiedGit User
145+ Commands
Follow theDOTS
Symmetric
subversion server
developer A developer B
chec
k in
update
check in
upda
te
Symmetric
Distributed
developer A developer B
blessed repo
developer A developer B
commitcommitcommit
commitcommit
commit commit
delete delete
rebase
push
push
push
push
pull
pull
Distributed
WorkingOffline
More available connectivity
More demand to work without connectivity
CheckinAddBranchList change logGrep historyRewrite historyStashMergeLabelRemovepractically everything but push
Offline Anything
Cool! Another commit to my latest OSS
project using Git!
I liked subversion better...
DVCS
What? Why?
Basic Use
Who? GUIs
Theory
Sharing
Interop High Points
Who’s Got Git?
GUIs
GitX
GitSafe
GitK
GitGUI
EGit
It’s Officia
l!
UsageModels
Central Repo
Ce
nt
ra
liz
ed
Blessed Repo
Dic
ta
to
rs
hip
Certified Repo
Development Repo
Int
eg
ra
tio
n M
an
ag
ed
Mirror
Development Repo
Mir
ro
re
d
Mirror
Certified Repo
Cu
st
om
+ P
ub
lic
Co
nt
rib
Customized
☚ P
riva
te
Pub
lic ☛
GitHub
Hashes and Git
‣Centralized VCS uses DB sequential index.
Index vs Hash
‣Git uses SHA-1 hash.
Index vs Hash
I thought
hashes were
for
passwords?
‣ Different goals.‣ Hash for the sake of integrity.‣ Hash for the sake of identity.
SHA-1 Hash
40 hex characters
Use as little of it as is unique
Treeish
Shorthand for the hashes
9AB223
9AB223^
9AB223..56CD77
HEAD
HEAD^
HEAD~3
But I’ve been
hearing news
about hash
collisions...
earth atoms10
49
SHA11046
stars10
22
sand grains10
20
collision10
19
‣Blob‣Tree‣Commit‣Tag
Hashable Objects
http://book.git-scm.com/1_the_git_object_model.html
Integrity‣ Identifies damaged repos.‣ Prevents modification of published history.‣ Unique to file size and contents.
Hash Benefits
Tags‣ Cryptographically sign tags by GPG.‣ Guarantee repo’s state at a point in time.
Hash Benefits
Storage Mechanics
Typical SCMs use delta storage
CVS / Subversion / darcs / Mercurial
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
Git uses DAG storage
Directed Acyclic Graph
Copy of the entire tree per checkin
cp -r srcfolder srcfolder.prev
Sounds inefficient...
zlib deflates every blob at commit
I’ve had a
400MB Subversion repo
convert to a 70MB Git repo
Speed
git: git
hg: mercurial
bzr: bazaar
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)
bazaar numbers plus network latency
subversion =
to100 timesFaster
10
Location,Location,Location
Three Stage Thinkingof Git
Git‣ git add‣ git commit‣ git push
‣ Commits only what is added to the index.‣ Opportunity to rewrite history locally.‣ Provides time to change your mind.‣ Selectively share with other repos.
Git‣ git stash‣ git stash apply
‣ Save work-in-progress temporarily, but safely.
‣ Merge stashed modifications back in.
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
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
Merge & Rebase
git branch newbranchgit checkout -b newer remote/branchnm
Cheap Branches
git show-branch --allgit branch -a
Cheap Branches
‣Local branch‣localbranchname
‣Remote branch‣remote/branchname
git merge --no-commit <sourcebranch>git merge --squash <sourcebranch>git merge <sourcebranch1> <sourcebranch2>
Merge Anything
git checkout myfeaturebranchgit rebase master
Rebase for Clarity
‣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
Standard
Mergea32
2e2
e69
d19
8b3
Branch
Mas
ter/
Trun
k/M
ainL
ates
t
9f1Merg
e
Rebasing
a32
2e2
e69
d19
8b3
Branch
Mas
ter/
Trun
k/M
ainL
ates
t
a32
2e2
e69
d19
8b3 Branch
Mas
ter/
Trun
k/M
ainL
ates
t
Rebase
a32
2e2
e69
d19
8b3 Branch
Mas
ter/
Trun
k/M
ainL
ates
t
e69
d19 Merge
DVCS
What? Why?
Basic Use
Who? GUIs
Theory
Sharing
Interop High Points
Sharing
Protocols‣ GIT‣ SSH‣ SCP
‣ Local file system‣ SAMBA
‣ HTTP‣ WebDAV
‣ rsync
Serving It Up
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
‣ 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
SVN Interop
git svn clone http://unfurl.com/trunkgit svn dcommit
Subversion
‣ First class compatibility.
‣ Round trip support.
‣ Git commits = svn commits.
Subversion
‣ git svn clone
Migration
‣ Power off your Subversion server.
Migration
reasons3
❸‣git cherry-pick a5b2ee
‣Merge in just one commit.
Cherry Pick
❷‣git grep SomeText HEAD^^^
‣Search blob contents history without checkouts.
Search History
❶‣git bisect run mvn test
‣Binary-search for bug.
‣Manual or automated modes.
Bisect Bugs
emergingVersion Control System
MatthewTwitter @matthewmccull
Blog http://www.ambientideas.com/blog sidebar has all my social media links
Email [email protected]
GitHub http://github.com/matthewmccullough
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
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
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
‣ 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