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.
Git in a Nutshell
         Sort of...

      Mathias Meyer
    www.paperplanes.de

   Ruby User Group Berlin
What the git?

• Git is not the next Subversion
• Git is a content tracker
• Git is almost a versioned file system
• Git is...
What the git?


• Git is a huge collection of commands
• Git is f***ing fast
Ancient History
• Developed to replace BitKeeper for the Linux
  kernel development
• Started out as a couple of scripts b...
Basics

• Every working copy is a full-fledged repository
• Git only tracks content
• Content is identified by a hash
• Thou...
Basics

• Everything is stored in one .git directory in the
  top level of your working copy
• Git uses an index to find ch...
Git Objects

• Git knows four types of objects
• Have SHA1 IDs
• Can be addressed with the six first bytes of
  the hash
• ...
Commits

• Refers to a tree and usually a parent commit
  (usually the commit before the current one)
• Can have two or mo...
Tree


• A simple structure containing names of blobs
  and other trees
• Represents a snapshot of the source tree
Blob

• Contains data, e.g. file content
• Blobs don’t have names
• Their names are derived from the tree
• Will be found t...
Tag


• Glued to a specific object
• Marks a specific point in the Git timeline with
  a name
HEAD




       branch




       commit




        tree




tree            blob




tree            blob




blob
Git Branches


• master - default development branch
• origin - default upstream branch
• HEAD - current branch
Git Branches
• HEAD~2, master^1, wtf?
• ~N references the Nth generation
  grandparent of a commit
• ^N references the Nth...
Git Branches
• HEAD~2 is the second generation grand-
  parent of the last commit on the current
  branch
• master^2 is th...
Git Branches


    Rrright.
Git Branches

• Branches are cheap and easy
• A branch is an ID pointing to a tree and a
  parent commit
• Merging is chea...
How Do I Get Git?

• MacPorts (port install git-core +svn)
• Git Installer for Leopard
• On every Linux distribution (apt-...
How Do I Get Started?

• mkdir project.git
• cd project.git
• git init
• Start hacking
How Do I Get Started?


• Or go to GitHub
• Best GUI for Git evah
Everyday Git


• Some of the commonly used Git commands
• Called the Porcelain
Set up camp


• git config --global user.name “Mathias Meyer”
• git config --global user.email
  “meyer@paperplanes.de”
git clone


• Creates a local working copy of a remote
  project
• git clone git://github.com/mattmatt/
  macistrano.git
git checkout

• Checks out code from a branch
• Will overwrite your local changes
• git checkout -b will create a branch a...
git branch

• Shows, creates and deletes branches
• git branch
    master
  * show_me_the_money
• git branch new_branch
• ...
git fetch


• Fetches all objects from a remote repository
  which are not in the local repository
git add


• Schedule changes in one or more files for the
  next commit
git rm



• Removes files
git mv



• Moves files and directories around
git commit
• Isn’t it obvious?
• It will check in your changes
• But only the ones you added
• Use git commit -a to check ...
git status


• Shows staged and unstaged changes
• staged = added
• unstaged = new, conflicts, changed
git push

• Pushes your changes to a remote repository
• git push origin pushes the current branch
• git push origin maste...
git pull


• Different way to do a merge
• git pull = git fetch + git merge
git log


• Shows the commit history
• Can be verbose if you want it to
git merge

• Merges the changes from a branch into your
  current branch
• git merge rails_2_1
• And that’s that
• In case...
git tag


• Duh!
• Associates a tag with the
git stash
• It’s like a clipboard in your repository
• Need to work on something else but don’t
  want to commit your loca...
git show


• Shows the details of a specified, or the last
  commit
git archive

• Creates an export of your repository
• Default is tar
• Convenient, no?
• git archive release_2_1 > release...
git ....

• There’s lots more
• Which you probably won’t need most of the
  time
• You use 20 or so for everyday work
• So...
Git-Svn

• The gateway drug for Subversion users
• Warning:You don’t want to use the svn
  command ever again
• Ever!
Git-Svn

• Basically a couple of Perl scripts
• Using the Subversion bindings
• Translates Subversion commits to Git commi...
Show me how!

• mkdir webistrano
• git svn init -s http://labs.peritor.com/svn/
  webistrano
• git svn fetch
• Get a coffe...
Everyday Git-Svn

• git checkout -b make_me_rich
• ...endless hours of coding...
• ...and writing tests...
• git add lib/m...
Everyday Git-Svn -
          Merging
• git commit -a
• git checkout master
• git svn rebase
• git merge make_me_rich
• ......
Everyday Git-Svn -
          Merging

• The potentiel downside of using git merge:
• git svn dcommit will check in all the...
Everyday Git-Svn -
          Merging

• The alternative
• dcommit from the branch
• rebase the changes on master
Everyday Git-Svn -
         Merging
• git commit -a
• git svn rebase # on branch make_me_rich
• git svn dcommit # on branc...
Some Git Awesomeness

• Find out what commits will be ci’d to svn
 • git svn dcommit -n (rather sparse)
 • git cherry -v t...
But I don’t like the CLI

• Use git gui for a “nicer” interface
• Use Gitk to visualize commits and branches
• For both: b...
In the end...

• Git will blow your brains out
• In several ways
• It takes a while to get used to it
• But it’s totally w...
The Bad Stuff

• Poor documentation, be prepared to spend
  some time on Google
• Complex beast, lots of small commands
• ...
Resources
• Git Home (http://www.git.or.cz)
• Git User’s Manual (http://www.kernel.org/pub/
  software/scm/git/docs/user-m...
Upcoming SlideShare
Loading in …5
×

of

Smalltalk on Git Slide 1 Smalltalk on Git Slide 2 Smalltalk on Git Slide 3 Smalltalk on Git Slide 4 Smalltalk on Git Slide 5 Smalltalk on Git Slide 6 Smalltalk on Git Slide 7 Smalltalk on Git Slide 8 Smalltalk on Git Slide 9 Smalltalk on Git Slide 10 Smalltalk on Git Slide 11 Smalltalk on Git Slide 12 Smalltalk on Git Slide 13 Smalltalk on Git Slide 14 Smalltalk on Git Slide 15 Smalltalk on Git Slide 16 Smalltalk on Git Slide 17 Smalltalk on Git Slide 18 Smalltalk on Git Slide 19 Smalltalk on Git Slide 20 Smalltalk on Git Slide 21 Smalltalk on Git Slide 22 Smalltalk on Git Slide 23 Smalltalk on Git Slide 24 Smalltalk on Git Slide 25 Smalltalk on Git Slide 26 Smalltalk on Git Slide 27 Smalltalk on Git Slide 28 Smalltalk on Git Slide 29 Smalltalk on Git Slide 30 Smalltalk on Git Slide 31 Smalltalk on Git Slide 32 Smalltalk on Git Slide 33 Smalltalk on Git Slide 34 Smalltalk on Git Slide 35 Smalltalk on Git Slide 36 Smalltalk on Git Slide 37 Smalltalk on Git Slide 38 Smalltalk on Git Slide 39 Smalltalk on Git Slide 40 Smalltalk on Git Slide 41 Smalltalk on Git Slide 42 Smalltalk on Git Slide 43 Smalltalk on Git Slide 44 Smalltalk on Git Slide 45 Smalltalk on Git Slide 46 Smalltalk on Git Slide 47 Smalltalk on Git Slide 48 Smalltalk on Git Slide 49 Smalltalk on Git Slide 50 Smalltalk on Git Slide 51 Smalltalk on Git Slide 52 Smalltalk on Git Slide 53
Upcoming SlideShare
Techoalien git
Next
Download to read offline and view in fullscreen.

8 Likes

Share

Download to read offline

Smalltalk on Git

Download to read offline

An introduction on using git and git-svn.

Related Books

Free with a 30 day trial from Scribd

See all

Smalltalk on Git

  1. 1. Git in a Nutshell Sort of... Mathias Meyer www.paperplanes.de Ruby User Group Berlin
  2. 2. What the git? • Git is not the next Subversion • Git is a content tracker • Git is almost a versioned file system • Git is distributed
  3. 3. What the git? • Git is a huge collection of commands • Git is f***ing fast
  4. 4. Ancient History • Developed to replace BitKeeper for the Linux kernel development • Started out as a couple of scripts built by Linus Torvalds • Used by Rails, Merb, Ubuntu, X.org, Wine, Rubinius and Linux (whoa!) • Started out focused on development with a central maintainer
  5. 5. Basics • Every working copy is a full-fledged repository • Git only tracks content • Content is identified by a hash • Though that content has a name • The same content is only stored once
  6. 6. Basics • Everything is stored in one .git directory in the top level of your working copy • Git uses an index to find changes in the working directory • The index is a snapshot of a specific tree in the repository
  7. 7. Git Objects • Git knows four types of objects • Have SHA1 IDs • Can be addressed with the six first bytes of the hash • Are compressed with gzip
  8. 8. Commits • Refers to a tree and usually a parent commit (usually the commit before the current one) • Can have two or more parents, then they represent a merge • Or no parent at all • Stored with a log message
  9. 9. Tree • A simple structure containing names of blobs and other trees • Represents a snapshot of the source tree
  10. 10. Blob • Contains data, e.g. file content • Blobs don’t have names • Their names are derived from the tree • Will be found through associations from trees and commits
  11. 11. Tag • Glued to a specific object • Marks a specific point in the Git timeline with a name
  12. 12. HEAD branch commit tree tree blob tree blob blob
  13. 13. Git Branches • master - default development branch • origin - default upstream branch • HEAD - current branch
  14. 14. Git Branches • HEAD~2, master^1, wtf? • ~N references the Nth generation grandparent of a commit • ^N references the Nth parent of a commit, only useful for merges of two or more commits • So....
  15. 15. Git Branches • HEAD~2 is the second generation grand- parent of the last commit on the current branch • master^2 is the second parent of the last commit on master • master~2^2 is the second parent of the second generation grand-parent of the last commit on the current branch
  16. 16. Git Branches Rrright.
  17. 17. Git Branches • Branches are cheap and easy • A branch is an ID pointing to a tree and a parent commit • Merging is cheap, fast and almost painless • Ergo: Branching in Git rocks
  18. 18. How Do I Get Git? • MacPorts (port install git-core +svn) • Git Installer for Leopard • On every Linux distribution (apt-get|rpm install git-core) • On Windows? I think so
  19. 19. How Do I Get Started? • mkdir project.git • cd project.git • git init • Start hacking
  20. 20. How Do I Get Started? • Or go to GitHub • Best GUI for Git evah
  21. 21. Everyday Git • Some of the commonly used Git commands • Called the Porcelain
  22. 22. Set up camp • git config --global user.name “Mathias Meyer” • git config --global user.email “meyer@paperplanes.de”
  23. 23. git clone • Creates a local working copy of a remote project • git clone git://github.com/mattmatt/ macistrano.git
  24. 24. git checkout • Checks out code from a branch • Will overwrite your local changes • git checkout -b will create a branch and check it out
  25. 25. git branch • Shows, creates and deletes branches • git branch master * show_me_the_money • git branch new_branch • git branch -d new_branch
  26. 26. git fetch • Fetches all objects from a remote repository which are not in the local repository
  27. 27. git add • Schedule changes in one or more files for the next commit
  28. 28. git rm • Removes files
  29. 29. git mv • Moves files and directories around
  30. 30. git commit • Isn’t it obvious? • It will check in your changes • But only the ones you added • Use git commit -a to check in all the changes without adding them • git commit <file> will commit the file without the need to add it
  31. 31. git status • Shows staged and unstaged changes • staged = added • unstaged = new, conflicts, changed
  32. 32. git push • Pushes your changes to a remote repository • git push origin pushes the current branch • git push origin master pushes the master branch
  33. 33. git pull • Different way to do a merge • git pull = git fetch + git merge
  34. 34. git log • Shows the commit history • Can be verbose if you want it to
  35. 35. git merge • Merges the changes from a branch into your current branch • git merge rails_2_1 • And that’s that • In case of conflicts, these need to be resolved and then committed
  36. 36. git tag • Duh! • Associates a tag with the
  37. 37. git stash • It’s like a clipboard in your repository • Need to work on something else but don’t want to commit your local changes yet? • git stash save will save all your changes • git stash apply will reapply them after you’re done • git stash list shows all the stashes • git stash show shows the changes of a stash
  38. 38. git show • Shows the details of a specified, or the last commit
  39. 39. git archive • Creates an export of your repository • Default is tar • Convenient, no? • git archive release_2_1 > release_2_1.tar
  40. 40. git .... • There’s lots more • Which you probably won’t need most of the time • You use 20 or so for everyday work • Some of them only on special occasions • git-<tab> and start digging
  41. 41. Git-Svn • The gateway drug for Subversion users • Warning:You don’t want to use the svn command ever again • Ever!
  42. 42. Git-Svn • Basically a couple of Perl scripts • Using the Subversion bindings • Translates Subversion commits to Git commits and vice versa
  43. 43. Show me how! • mkdir webistrano • git svn init -s http://labs.peritor.com/svn/ webistrano • git svn fetch • Get a coffee...
  44. 44. Everyday Git-Svn • git checkout -b make_me_rich • ...endless hours of coding... • ...and writing tests... • git add lib/monetize.rb spec/monetize_spec.rb • git commit
  45. 45. Everyday Git-Svn - Merging • git commit -a • git checkout master • git svn rebase • git merge make_me_rich • ...run tests... • git svn dcommit • git branch -d make_me_rich
  46. 46. Everyday Git-Svn - Merging • The potentiel downside of using git merge: • git svn dcommit will check in all the commits from the branch in one single svn commit
  47. 47. Everyday Git-Svn - Merging • The alternative • dcommit from the branch • rebase the changes on master
  48. 48. Everyday Git-Svn - Merging • git commit -a • git svn rebase # on branch make_me_rich • git svn dcommit # on branch make_me_rich • git checkout master • git svn rebase • git branch -d make_me_rich
  49. 49. Some Git Awesomeness • Find out what commits will be ci’d to svn • git svn dcommit -n (rather sparse) • git cherry -v trunk (full glory) • Commit partial changes of a file • git add --patch
  50. 50. But I don’t like the CLI • Use git gui for a “nicer” interface • Use Gitk to visualize commits and branches • For both: brace yourself to be blinded • Much nicer, less powerful: GitNub • TextMate bundle!
  51. 51. In the end... • Git will blow your brains out • In several ways • It takes a while to get used to it • But it’s totally worth it • Even if you’re still using Subversion as a central repository
  52. 52. The Bad Stuff • Poor documentation, be prepared to spend some time on Google • Complex beast, lots of small commands • No API
  53. 53. Resources • Git Home (http://www.git.or.cz) • Git User’s Manual (http://www.kernel.org/pub/ software/scm/git/docs/user-manual.html) • Git PeepCode (http://peepcode.com/products/ git) • Must-read: Git Internals (http://peepcode.com/ products/git-internals-pdf) • GitCasts (http://www.gitcasts.com/)
  • eiyaya

    Mar. 12, 2014
  • wphsieh

    Aug. 14, 2013
  • changfoo

    Jul. 21, 2012
  • ulinkwo

    Jul. 8, 2011
  • kevinj

    Aug. 24, 2010
  • stonegao

    Jun. 1, 2009
  • ev0

    May. 10, 2009
  • ellenfeaheny

    Jan. 4, 2009

An introduction on using git and git-svn.

Views

Total views

6,121

On Slideshare

0

From embeds

0

Number of embeds

27

Actions

Downloads

165

Shares

0

Comments

0

Likes

8

×