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

An Introduction to Git

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

An Introduction to Git

Avatar for James Herdman

James Herdman

May 31, 2012
Tweet

Other Decks in Technology

Transcript

  1. Who Am I? • James Herdman • Ruby and JavaScript

    programmer • Work for Celect.org • Git user for 3 years Thursday, 31 May, 12
  2. Goals • Basic Git workflow • Build a strong foundation

    • Point you towards your next step Thursday, 31 May, 12
  3. Our Journey • Git at a Glance • What is

    Version Control? • Using Git Thursday, 31 May, 12
  4. • Version Control System • Supports non-linear development • Cryptographic

    authentication of history • UNIX principles • Bloody fast Git at a Glance Thursday, 31 May, 12
  5. Version Control • Managing changes to documents • Prevent loss

    of work • Sharing documents safely • Maintain versions of documents Thursday, 31 May, 12
  6. It’s All About Changes • Change: a difference in content

    • History: a collection of changes • Loss of work: loss of changes • Version: collection of documents, at a point in time Thursday, 31 May, 12
  7. ~blog ➜ git status # On branch master # #

    Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # #" lorem.txt nothing added to commit but untracked files present (use "git add" to track) Thursday, 31 May, 12
  8. What’s a Commit? • A change, recorded and tracked by

    Git • A point in a project’s history Thursday, 31 May, 12
  9. Making a Commit 1. Make a change 2. Track it

    3. Commit it Thursday, 31 May, 12
  10. ~blog ➜ git status # On branch master # #

    Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # #" new file: lorem.txt # Thursday, 31 May, 12
  11. ~blog ➜ git commit -m "Initial blog entry" [master (root-commit)

    5a93468] Initial blog entry 1 files changed, 5 insertions(+), 0 deletions(-) create mode 100644 lorem.txt Thursday, 31 May, 12
  12. ~blog ➜ git status # On branch master nothing to

    commit (working directory clean) Thursday, 31 May, 12
  13. ~blog ➜ git status # On branch master # Changed

    but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # #" modified: lorem.txt # no changes added to commit (use "git add" and/or "git commit - a") Thursday, 31 May, 12
  14. ~blog ➜ git status # On branch master # Changes

    to be committed: # (use "git reset HEAD <file>..." to unstage) # #" modified: lorem.txt # Thursday, 31 May, 12
  15. ~blog ➜ git commit -m "Start of a new line"

    [master 3584954] Start of a new line 1 files changed, 4 insertions(+), 1 deletions(-) Thursday, 31 May, 12
  16. What Happened? • Change given unique ID • SHA hex

    digest of the change itself • Stored in Git’s log (the history) Thursday, 31 May, 12
  17. ~blog ➜ git show -p commit 35849545dae48e9b3d073f77a868f8978c95e5a5 Author: James F.

    Herdman <[email protected]> Date: Mon Dec 13 20:00:35 2010 -0500 Start of a new line diff --git a/lorem.txt b/lorem.txt index 1184641..0e2bb4f 100644 --- a/lorem.txt +++ b/lorem.txt @@ -2,4 +2,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce e Maecenas id erat sem, id eleifend nulla. Phasellus eget risus egestas erat cons -Quisque vel mi quis nisl gravida consequat ut vel erat. Cras blandit mollis sap \ No newline at end of file +Quisque vel mi quis nisl gravida consequat ut vel erat. Cras blandit mollis sap + +There once was a tool named Git, +that Linus was sure would be a hit. Thursday, 31 May, 12
  18. Branching • Divergence from main path • Isolate new ideas

    • Allow for safe collaboration Thursday, 31 May, 12
  19. ~snipmate.vim ➜ git branch better-javascript-snippets ~snipmate.vim ➜ git branch better-javascript-snippets

    * master ~snipmate.vim ➜ git checkout better-javascript-snippets Switched to branch 'better-javascript-snippets' ~snipmate.vim ➜ git branch * better-javascript-snippets master Thursday, 31 May, 12
  20. ~snipmate.vim ➜ git branch * better-javascript-snippets master ~snipmate.vim ➜ git

    checkout master Switched to branch 'master' Your branch is ahead of 'origin/master' by 1 commit. ~snipmate.vim ➜ git merge better-javascript-snippets Merge made by recursive. snippets/javascript.snippets | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) ~snipmate.vim ➜ git status # On branch master # Your branch is ahead of 'origin/master' by 5 commits. # nothing to commit (working directory clean) Thursday, 31 May, 12
  21. ~snipmate.vim ➜ git status # On branch master # Your

    branch is ahead of 'origin/master' by 5 commits. # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # #" modified: javascript.snippets # no changes added to commit (use "git add" and/or "git commit -a") Thursday, 31 May, 12
  22. ~snipmate.vim/ ➜ git stash Saved working directory and index state

    WIP on master: 604f234 Merge branch 'better-javascript-snippets' HEAD is now at 604f234 Merge branch 'better-javascript-snippets' Thursday, 31 May, 12
  23. ~snipmate.vim ➜ git status # On branch master # Your

    branch is ahead of 'origin/master' by 5 commits. # nothing to commit (working directory clean) Thursday, 31 May, 12
  24. ~snipmate.vim ➜ git stash pop # On branch master #

    Your branch is ahead of 'origin/master' by 5 commits. # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # #" modified: snippets/javascript.snippets # no changes added to commit (use "git add" and/or "git commit -a") Dropped refs/stash@{0} (b7033f1c44071a8d69a4c8d4716b5781ac117e97) Thursday, 31 May, 12
  25. What’s Next? • Pushing • Pulling • Cherry picking •

    Tagging • Workflows • More! Thursday, 31 May, 12
  26. • Git for Designers. http://hoth.entp.com/ output/git_for_designers.html • The Git Parable.

    http://tom.preston- werner.com/2009/05/19/the-git-parable.html • Pro Git. http://progit.org • Git homepage. http://git-scm.com What’s Next? Thursday, 31 May, 12