• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Git primer
 

Git primer

on

  • 3,807 views

A brief introduction to distributed version control with git.

A brief introduction to distributed version control with git.
Shamelessly adapted from Scott Chacon's excellent "Getting Git" talk: http://www.slideshare.net/chacon/getting-git

Statistics

Views

Total Views
3,807
Views on SlideShare
3,802
Embed Views
5

Actions

Likes
4
Downloads
62
Comments
1

1 Embed 5

http://www.linkedin.com 5

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Inspired by:Getting Git by Scott Chacon — http://www.slideshare.net/chacon/getting-gitThe git Community Book — http://book.git-scm.com/index.htmlPicture: Larry the Cable Guy

Git primer Git primer Presentation Transcript

  • gitr’ done!
    A brief introduction to
    distributed version control with git
    Oscar Nierstrasz — University of Bern — scg.unibe.ch
  • Why git?
  • Bob
  • Bob
    Carol
  • Bob
    Carol
    Alice
    Ted
  • Bob
    Carol
    Alice
    Ted
    A recipe for disaster!
  • The git object model
  • A “blob” is content under version control (a file)
    blob
  • You can have trees of blobs
    (directories of files)
    tree
    blob
    tree
    blob
    blob
  • A “commit” is a tree of blobs
    (a set of changes)
    commit
    tree
    blob
    tree
    blob
    blob
  • Most commits modify (or merge) earlier commits
    commit
    commit
    tree
    tree
    blob
    blob
    tree
    blob
    blob
  • You can “tag” an interesting commit
    tag
    commit
    commit
    tree
    tree
    blob
    blob
    tree
    blob
    blob
  • A graph of commits may belong to a branch
    branch
    tag
    commit
    commit
    tree
    tree
    blob
    blob
    tree
    blob
    blob
  • HEAD
    “HEAD “is the current branch
    branch
    tag
    commit
    commit
    tree
    tree
    blob
    blob
    tree
    blob
    blob
  • HEAD
    branch
    commit
    commit
    Let’s focus on commits and branches
  • Basic git
  • Create a git repo
    HEAD
    mkdir repo
    cd repo
    git init
    master
    C0
  • Tell git to “stage” changes
    HEAD
    git add …
    master
    C0
  • HEAD
    Commit your changes
    master
    C1
    git commit …
    C0
  • Collaborating
  • John
    Jane
    Public repo
    Local repo
    Local repo
    master
    C1
    C0
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git clone …
    master
    master
    master
    C1
    C1
    C1
    C0
    C0
    C0
    git clone …
  • John
    Jane
    Public repo
    Local repo
    Local repo
    master
    master
    master
    C1
    C2
    C3
    C0
    C1
    C1
    C0
    C0
    git add …
    git commit …
    git add …
    git commit …
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git pull
    master
    master
    master
    C1
    C2
    C3
    C0
    C1
    C1
    C0
    C0
    (nothing new to pull)
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git push
    master
    master
    master
    C2
    C2
    C3
    C1
    C1
    C1
    C0
    C0
    C0
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git fetch
    master
    master
    master
    C2
    C2
    C3
    C2
    C1
    C1
    C1
    C0
    C0
    C0
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git merge
    master
    master
    master
    C2
    C4
    C2
    C3
    C2
    C1
    C1
    C1
    C0
    C0
    C0
    NB:git pull = fetch + merge
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git push
    master
    master
    master
    C4
    C4
    C2
    C3
    C2
    C3
    C2
    C1
    C1
    C1
    C0
    C0
    C0
  • John
    Jane
    Public repo
    Local repo
    Local repo
    git pull
    master
    master
    master
    C4
    C4
    C4
    C3
    C3
    C2
    C2
    C3
    C2
    C1
    C1
    C1
    C0
    C0
    C0
  • Branching and merging
  • “origin” refers to the remote repo
    HEAD
    master
    origin/master
    C1
    C0
  • HEAD
    master

    git commit …
    origin/master
    C2
    C1
    C0
  • git branch tryout
    HEAD
    tryout
    master
    origin/master
    C2
    C1
    C0
  • git checkout tryout
    HEAD
    tryout
    master
    origin/master
    C2
    C1
    NB:git checkout –b … = branch + checkout
    C0
  • HEAD
    tryout
    master
    git commit …
    C3
    origin/master
    C2
    C1
    C0
  • HEAD
    tryout
    master
    C3
    C5
    origin/master
    C2
    C1
    origin/idea
    C4
    C6
    C0
    git fetch origin
  • git merge origin/master origin/idea
    HEAD
    tryout
    C7
    master
    C3
    origin/master
    C5
    C2
    C1
    C4
    C6
    C0
    origin/idea
  • git checkout master
    tryout
    HEAD
    C7
    master
    C3
    origin/master
    C5
    C2
    C1
    C4
    C6
    C0
    origin/idea
  • git merge
    HEAD
    tryout
    master
    C7
    C8
    C3
    origin/master
    C5
    C2
    C1
    C4
    C6
    C0
    origin/idea
  • git push
    HEAD
    tryout
    master
    C7
    origin/master
    C8
    C3
    C5
    C2
    C1
    C4
    C6
    C0
    origin/idea
  • More to git
  • More to git …
    Merging and mergetool
    Squashing commits when merging
    Resolving conflicts
    User authentication with ssh
    gitx and other graphical tools
    git configure — remembering your name
    git remote — multiple remote repos
    github — an open source public repo

  • Resources
    http://book.git-scm.com/index.html
    http://git-scm.com/
    https://github.com/
    http://www.slideshare.net/chacon/getting-git
    http://oreilly.com/
  • License
    Attribution-ShareAlike 2.5
    You are free:
    • to copy, distribute, display, and perform the work
    • to make derivative works
    • to make commercial use of the work
    Under the following conditions:
    Attribution. You must attribute the work in the manner specified by the author or licensor.
    Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
    • For any reuse or distribution, you must make clear to others the license terms of this work.
    • Any of these conditions can be waived if you get permission from the copyright holder.
    Your fair use and other rights are in no way affected by the above.
    http://creativecommons.org/licenses/by-sa/2.5/