Gotta get GitChris Sherwood and Alfredo Aretxabaleta
USGS Woods Hole
Git documentation
• Git - - distributed-is-the-new-centralizedhttp://git-scm.com/doc
• Git for SVN usershttp://git-scm.com/course/svn.html
• “Pro Git” – Scott Chacon (also online)• “Pragmatic Guide to Git” – Travis Swicegood• CRS attempts
http://csherwood.tiddlyspot.com/
Advantages
• Designed for distributed development– All local repos are complete– Anybody can make a local archive– You can pull from any archive you have access to
• Most operations are local (faster, work offline)• Integrity: everything is check-summed• Only adds data (maybe safer)• Lightweight, local branches• GUI tools and hosting services similar SVN
Disadvantages
• A(nother) learning curve• Sometimes TM(U)I
• Also, sometimes too much typing
Installation
• Linux, Cygwin often have git, but if not:$ sudo apt-get install git-core
• Mac can get it via MacPorts$ sudo port install git-core +svn +doc +bash_completion +gitweb
• Windowshttp://code.google.com/p/msysgit
Modified after “Pro Git”
First-time user setup
Important$ git config --global user.name “csherwood (ubuntu)“$ git config --global user.email [email protected]
Optional$ git config --global core.editor xemacs$ git config --global merge.tool meld
Check settings$ git config --list Modified after “Pro Git”
Centralized Repository
From “Pro Git”
Distributed Repositories
From “Pro Git”
ROMS and CSTMS SVN
CSTMS trunk
crs branch
dev3 branch
dev2 branch
ROMS trunk
crs branchworking copy
crs trunkworking copy
Hernan trunkworking copy
svn copy
svn checkoutsvn updatesvn commit
svn checkoutsvn updatesvn commit
svn checkoutsvn update
?
? ?
COAWST GIT
crs origin/master
COAWST origin/master
crsmaster
sed branchtrack kumar branch
Warnermaster
track kumar branchtrack crs branch
...
git fetchgit pullgit push
git clone
kumar origin/master
kumarmaster
wec branch
git pullgit push
git pullgit pushgit fetch
git fetch
Branch Development
waves
seds
Modified after “Pro Git”
Arrows point back to snapshots
First attempt
• Check out copy COAWST from SVN• Export from SVN to gcoawst• In gcoawst
git initgit add *git commit
• Make a bare repository (no working dir)git clone --bare gcoawst gcoawst.gitscp –r gcoawst.git [email protected]:/peach/data2/csherwood/src/gcoawst.git
First attempt, second page
• crs cloned it• ala cloned it• ala made a branch and switched to it• ala added the new sediment stuff to the branch and
committed it• crs made a branch that tracked ala’s repo• crs fetched ala’s changes• crs merged them into his master• crs pushed them up to the repository• new users can clone/pull new sediment stuff from the
repository
A few things we could not have done with SVN
• Made our own shared repository based on the source repo (without admin)
• Merged Alfredo’s branch into my branch without going to a repo
• Its faster…• …but confusing
If we wanted to try it…
• Pick a stopping point…maybe make a tagged SVN release
• Use the tools to port the SVN history to git• Let John work on it for a while, allowing
people to clone it• Pick a project to track, and work out the
protocol for tracking branches• Hey, if Linus Torvalds can do it….