Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git in 5 Minutes

Rob Dumas
February 13, 2013

Git in 5 Minutes

A shorter version of my earlier talk, this time presented at Code4Lib 2013. You can also view the video of me giving the talk on Archive.org. http://archive.org/details/Code4libRobDumas

Rob Dumas

February 13, 2013
Tweet

More Decks by Rob Dumas

Other Decks in Programming

Transcript

  1. in 5 minutes
    r2d.to/gitstart

    View Slide

  2. snapshots

    View Slide

  3. snapshots

    View Slide

  4. git-scm.com

    View Slide

  5. ✓ what files have changed
    ✓ who made those changes
    ✓ when the changes were made
    ✓ how those changed files differ
    ✓ why they were changed
    (hopefully)
    version control

    View Slide

  6. wikipedia
    record of changes
    to articles over
    time

    View Slide

  7. ✓free & open source
    ✓local & distributed
    ✓fast & secure
    ✓stable & popular
    what’s so great about git?

    View Slide

  8. getting git
    installing it
    baked right in
    textmate
    bundle
    xcode
    and
    more!
    eclipse
    plugin
    use homebrew
    mxcl.github.com/homebrew
    use apt-get or yum
    download it
    git-scm.com/downloads

    View Slide

  9. basic workflow
    create/
    clone
    repository
    make
    changes
    commit
    changes
    stage changes
    1
    2
    3
    4

    View Slide

  10. photo credit: muy yum (flic.kr/p/7ByV6Y)
    stage
    work area
    git

    View Slide

  11. git basics

    View Slide

  12. creating a repository
    $  cd  myproject
    $  git  init

    View Slide

  13. myproject/.git/
    don’t touch these files!

    View Slide

  14. cloning a repository
    $  git  clone  https://github.com/
    progit/progit.git
    folder or URL
    the location can be a folder or url

    View Slide

  15. staging changes
    $  git  add  myfile.html
    $  git  add  css/*
    you have to stage your changes
    each time you commit!

    View Slide

  16. committing changes
    $  git  commit  -­‐m  "Added  
    new  file,  myfile.html,  
    to  repo."

    View Slide

  17. other commands
    $  git  log
    $  git  diff  a65fe40
    $  git  rm
    $  git  mv commit hash

    View Slide

  18. .gitignore
    source/*
    *.temp
    nuclear-­‐launch-­‐codes.txt
    put files, folders and patterns in
    this file to tell git to ignore them.

    View Slide

  19. branching & merging
    master
    development
    feature

    View Slide

  20. branching
    $  git  branch  child
    $  git  checkout  child
    1. create child branch
    2. check out child branch
    3. work on new branch

    View Slide

  21. merging
    $  git  checkout  parent
    $  git  merge  child
    1. check out parent branch
    2. merge child branch into parent

    View Slide

  22. tagging
    $  git  tag  -­‐a  v1.0  -­‐m  "Product  release"
    $  git  tag  -­‐a  ronburgundy  -­‐m  "Brick  
       killed  a  guy  with  a  trident."
    master
    development
    v1.0

    View Slide

  23. distributed git
    shared
    repository
    developer
    developer
    developer
    $  git  pull  origin  master
    $  git  push  origin  master

    View Slide

  24. further
    reading

    View Slide

  25. get started with git
    alistapart.com/articles/get-started-with-git

    View Slide

  26. Version Control
    with Git
    2nd. Edition
    by Loeliger & McCullough
    © 2012 O’Reilly Media
    ISBN 978-1-4493-1638-9
    r2d.to/oreillygitbook

    View Slide

  27. ✓git-scm.com/book
    ✓git-scm.com/videos
    ✓gitready.com
    ✓gitref.org
    ✓gitcasts.com
    ✓gitimmersion.com
    ✓try.github.com
    ✓help.github.com
    ✓codeschool.com/
    courses/git-real
    useful links

    View Slide

  28. rob dumas
    chicago public library
    @stray
    thank you, code4lib!
    r2d.to/gitstart

    View Slide