Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The everyday developer's guide to version control with Git


Published on

A introductory presentation on using Git for version control management.

Published in: Technology
  • Erh -- you can't perform a commit with an empty index (which is what I think you are implying above), unless you specify --allow-empty to the commit command. e.g.

    $ git commit -m 'initial commit' --allow-empty
    [master (root-commit)]: created 24d18cd: 'initial commit'
    Are you sure you want to  Yes  No
    Your message goes here

The everyday developer's guide to version control with Git

  1. The everyday developer’s guide to version control with git
  2. so, what’s git?
  3. “ Git is distributed version control system focused on speed, effectivity and real- world usability on large projects. -
  4. basic source control system (example)
  5. but why git?
  6. lots of people use it (it’s common)
  7. let’s git started
  8. create (initialize) a repository $ cd (project-directory) $ git init Initialized empty Git repository in .git/
  9. your first save (commit) $ git commit -m 'Initial commit'
  10. create some files $ touch README
  11. see what’s changed $ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)
  12. adding files Adding a individual file $ git add README Adding a multiple files $ git add .
  13. see what’s changed (again) $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README #
  14. save (commit) your changes $ git commit -m 'Added README file' Created initial commit c1195b5: Added README file 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README
  15. check your history $ git log commit c1195b51d6e99dcc6e88b6ae44eea20ba1f0868e Author: Erin Carter <> Date: Thu Oct 29 12:21:24 2009 -0500 Added README file
  16. developing with git
  17. undoing your changes $ git checkout README
  18. reverting to specific version $ git checkout 3607253d20c7a295965f798109f9d4af0fbeedd8 <file name>
  19. reverting back $ git reset HEAD <file name>
  20. developing parallel with branching
  21. create a branch $ git checkout -b bugfix Switched to a new branch “bugfix”
  22. switching branches $ git status # On branch bugfix nothing to commit (working directory clean) $ git checkout master Switched to branch “master”
  23. collaborating with git
  24. public repos = free private repos = cheap
  25. clone a hosted repository $ git clone git:// world.git Initialized empty Git repository in /Users/me/Projects/hello- world/.git/ remote: Counting objects: 158, done. remote: Compressing objects: 100% (79/79), done. remote: Total 158 (delta 54), reused 157 (delta 54) Receiving objects: 100% (158/158), 15.62 KiB, done. Resolving deltas: 100% (54/54), done. $ cd hello-world
  26. pull changes (and pull often) $ git pull origin master
  27. add changes to master $ git checkout master $ git merge bugfix
  28. push changes $ git push origin master
  29. configure & customize git
  30. configuring $ git config --global "Erin Carter" $ git config --global ""
  31. add pretty colors $ git config --global color.diff auto $ git config --global color.status auto $ git config --global color.branch auto
  32. git tools
  33. gitk usually comes with git -
  34. GitX
  35. TortoiseGit
  36. git resources
  37. Pro Git (book) free online at
  38. Pragmatic Version Control Using Git (book)
  39. Git Community Book
  40. Git Cheat Sheet
  41. what to remember ‣ commit often ‣ pull often ‣ use checkout and reset with caution ‣ create your own repository anywhere
  42. fin
  43. @erincarter illustrations by Simon Oxley of theme inspired by Scott Chacon’s