Your SlideShare is downloading. ×
  • Like
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Brett Smith's Spring 2011 presentation on Git, the popular open source version control system.

Brett Smith's Spring 2011 presentation on Git, the popular open source version control system.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • Version Control – Who has ever made a backup of some source code before making a major change to it? That’s a basic form of version control. You also see version control on Wikipedia, with it’s storage of change history.Modern version control software usually includes the following: * Manages changes * Allows multiple developers to work together on the same project, even the same file * Merge those changes * Track who changed what and when * Maintain multiple lines of development at a timeFast – Git was built by Linus Torvalds (Chief architect of the Linux kernel). Git was built from the ground up with speed in mind, and takes advantage of an intimate knowledge of the Linux kernel to do what it needs to do quickly. This means that Windows performance and support wasn’t very good before Git started gaining a lot popularity.Distributed – Instead of just having the version history on your machine or a server machine, the version history is kept on ALL clients. Calling one particular machine with the history the server is artificial, since it knows just as much as any of the clients do, but it’s often convenient to have your development efforts focus around one central machine.This distribution also makes Git that much faster. You don’t have to use any network operations to request project history or to look at differences between files, because you already have all that information locally. You’ll still be able to make changes when you don’t have access to the Internet and to record those changes in your local database. When you have Internet again, you’ll sync those changes with the other developers.
  • Now I’ll go over some basic terminology in Git that is very important to understand if you want to use Git.Modified – Literally, you have modified a file, but you haven’t interacted with Git on any way with your modification yet.Staged – You inform Git to pay attention to your modification AS IT CURRENTLY IS (Git makes a copy). This is also sometimes referred to as the index.Committed – Git has recorded your modification for the benefit of future generations.
  • Git add is also called “staging the files”Git reset copies files from the latest commit into the stage. This is an “unstage” operation.Git checkout copies files from the stage to your working directory. Use this to throw away modifications to files.
  • All commands in git are “git”, space, followed by a verb.Git init creates a new git repository in the current directory. Nothing is tracked yet.Using .gitignore, git status, and git reset – filesUse git mv to move files, same as mv, git add, git rm. Git is very intelligent about file movement.
  • Git clone clones the ENTIRE repository. That is, a snapshot of each file at each revision. This means that all operations will be lightening fast since they’re all local, but it does have the downside that git clone might take a while with larger repositories.Git pull “pulls” any changes made to the remote repository (the one at the location specified in git clone) into your local repository.Git push pushes any changes committed to the local repository to the remote repository.
  • Git log –pretty = one of oneline, short, medium, full, fuller, email, raw
  • What is a branching? It means you diverge from the main line of development and continue to do work without making any changes to the main line. For example, branches are commonly made for maintenance development from previous releases, so the main line can be devoted to current work with the latest major revisions. Or, you might make a branch for working on a particularly large bug fix. Or, simply an experimental branch to see if a series of changes can improve the software any. If they do, they’re easily merged back in, if it doesn’t, no harm done to the main line.Branching is often hailed as one of Git’s strongest points. It’s so simple, convenient, and elegant and fast to create branches and merge them in again that it’s often referred to as Git’s killer feature.
  • Git does a three way merge here.
  • This is the first commit in a repository, a commit that contains three files. The blobs represent each file, the tree object is the root folder which contains pointers to each file in the folder, and the commit object contains a pointer to the root folder.Git stores file snapshots at each revision, not deltas (diffs). File that change have an entirely new object devoted to the new file. If a file stays the same, the new tree object for the commit points to the same blob.
  • Here is the same repository after two more commits. Each of the blue objects is the new tree object representing the root directory of the commit.
  • Here’s the same repository, but showing the masterbranchSo what happens when we create another branch for the repository?...
  • This is all well and good, but how does Git know what branch or commit we’re currently working with in the working directory? …
  • It turns out that Git has a special pointer to what we’re currently working withSo what happens if we switch to the testing branch and make a commit?
  • So what happens if we switch back to the master branch, change some files, and commit?
  • Bisect lets you perform a binary search across commits, searching for the origin of a particular bug


  • 1. Git
    From noob to pro
  • 2. Version Control
    What is Git?
  • 3. “Git made me a more productive coder because it showed me how much progress I had made” – Thomas “Synk” Kelley
    “I use Git because the commands are really easy to use. I use Git because if I want to set up a Git server on the Internet it does not require any extra processes on my server, all I need is an SSH connection” – Chris “Panda” Nord
    Why Git?
  • 4. Modified – I modified a file
    Staged – Git has taken a snapshot of my modification
    Commited – Git has permanently recorded my modifications from the stage
    The three file stages in Git
  • 5. The three file stages in Git
  • 6. git init
    git add files
    git commit –m ‘my commit message’
    A new Git repository
  • 7. ..What just happened?
  • 8. ..What just happened?
  • 9. git clone location
    git clone
    gitclone git://
    git pull
    git push
    An existing repository
  • 10. gitdiff
    git revert
    git checkout
    git log
    git blame
    git tag
    Useful commands
  • 11. git branch new_branch
    git checkout new_branch
  • 12. Branching
  • 13. Merging
  • 14. Merging
  • 15. Implementation detail
  • 16. Implementation detail
  • 17. Implementation detail
  • 18. Implementation detail
  • 19. Implementation detail
  • 20. Implementation detail
  • 21. Implementation detail
  • 22. Interactive staging
    Other notables!
  • 23. Questions?
  • 24. Images taken from and