in 5 minutes

r2d.to/gitstart
BACKUPS ARE
                                                 REALLY F**KING
                                                 IMPORTANT
photo credit: alexander muse (flic.kr/p/noL2K)
snapshots
snapshots
version control
✓   what files have changed
✓   who made those changes
✓   when the changes were made
✓   how those changed files differ
✓   why they were changed
    (hopefully)
wikipedia
record of changes
 to articles over
       time
git-scm.com
what’s so great about git?
  ✓ free & open source
  ✓ local & distributed
  ✓ fast & secure
  ✓ stable & popular
getting git
     baked right in   installing it
                        use homebrew
                        mxcl.github.com/homebrew

textmate    eclipse
 bundle     plugin      use apt-get or yum

            a nd        download it
 xcode      mo re !     git-scm.com/downloads
what’s so great about git?
✓ free & open source
✓ local & distributed
✓ fast & secure
✓ stable & popular
create/ 1
         basic workflow
clone
repository                             commit
                2                  4   changes
             make
             changes


                         3
                   stage changes
work area




       git




                                              stage
photo credit: muy yum (flic.kr/p/7ByV6Y)
git basics
creating a repository
$	
  cd	
  myproject
$	
  git	
  init
myproject/.git/


don’t touch these files!
cloning a repository                folder or URL


$	
  git	
  clone	
  https://github.com/
progit/progit.git


      the location can be a folder or url
staging changes
$	
  git	
  add	
  myfile.html
$	
  git	
  add	
  css/*

     you have to stage your changes
         each time you commit!
committing changes
$	
  git	
  commit	
  -­‐m	
  "Added	
  
new	
  file,	
  myfile.html,	
  
to	
  repo."
other commands
$	
  git	
  log
$	
  git	
  diff	
  a65fe40
$	
  git	
  rm
$	
  git	
  mv                commit hash
.gitignore
source/*
*.temp
nuclear-­‐launch-­‐codes.txt

    put files, folders and patterns in
   this file to tell git to ignore them.
branching & merging
 master




    development

                  feature
branching
    1. create child branch
    2. check out child branch
    3. work on new branch
$	
  git	
  branch	
  child
$	
  git	
  checkout	
  child
merging
1. check out parent branch
2. merge child branch into parent

$	
  git	
  checkout	
  parent
$	
  git	
  merge	
  child
the ‘stache
the ‘stache
the stash
$	
  git	
  stash
$	
  git	
  stash	
  apply
$	
  git	
  stash	
  list
$	
  git	
  stash	
  drop	
  
	
  	
  	
  STASH_ID
master
                    tagging                         v1.0




         development

$	
  git	
  tag	
  -­‐a	
  v1.0	
  -­‐m	
  "Product	
  release"

$	
  git	
  tag	
  -­‐a	
  ronburgundy	
  -­‐m	
  "Brick	
  
killed	
  a	
  guy	
  with	
  a	
  trident."
distributed git
      developer

                             shared
      developer
                           repository

      developer



$	
  git	
  pull	
  origin	
  master
$	
  git	
  push	
  origin	
  master
thank you, code4lib!
  r2d.to/gitstart
        rob dumas
        chicago public library
        @stray

Git in 5 Minutes