Your SlideShare is downloading. ×
0
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Understanding Git Internals
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Understanding Git Internals

1,681

Published on

This is a quick introduction to the inner workings of Git, largely based on what I learned from reading Git Internals (https://peepcode.com/products/git-internals-pdf) and experimentation. It covers …

This is a quick introduction to the inner workings of Git, largely based on what I learned from reading Git Internals (https://peepcode.com/products/git-internals-pdf) and experimentation. It covers Git objects (blob, tree, commit, tag), references, and branches with incrementally building diagrams to help convey the concepts.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,681
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
59
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. GitUnderstanding January 6, 2010 Jeff Kunkle
  • 2. What’s Git? Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with completehistory and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
  • 3. Working Directory ./ Rakefile init.rb lib grant.rb
  • 4. Working Directory ./ .git Rakefile init.rb lib grant.rb>git init
  • 5. Working Directory ./ .git What’s in here? Rakefile init.rb lib grant.rb>git init
  • 6. Objects
  • 7. Git Objects header object_type [content size]0 content of the file can be textcontent can be binary can be whatever Zlib::Deflate
  • 8. Git Objects header object_type [content size]0 content of the file can be text content can be binary can be whatever Zlib::Deflate1 Blob 2 Tree 3 Commit 4 Tag
  • 9. 1 Blobs
  • 10. Working Directory Git Directory ./ Rakefile init.rb lib grant.rb
  • 11. Working Directory Git Directory ./ Rakefile init.rb lib grant.rb>git add .>git commit -m “initial commit”
  • 12. Working Directory Git Directory ./ Rakefile blob : 21a307 init.rb blob : 644eda lib grant.rb blob : a22a24>git add .>git commit -m “initial commit”
  • 13. Working Directory Git Directory ./ Rakefile blob : 21a307 init.rb blob : 644eda SHA-1 hashes lib of file content grant.rb blob : a22a24>git add .>git commit -m “initial commit”
  • 14. Blob Content
  • 15. Blob Content %w{ models }.each do |dir| path = File.join(File.dirname(__FILE__), lib, app, dir) $LOAD_PATH << path ActiveSupport::Dependencies.load_paths << path ActiveSupport::Dependencies.load_once_paths.delete(path) end>git cat-file -p 644eda
  • 16. 2 Trees
  • 17. Working Directory Git Directory ./ Rakefile blob : 21a307 init.rb blob : 644eda lib grant.rb blob : a22a24
  • 18. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  • 19. Tree Content
  • 20. Tree Content 100644 blob 21a30738954b6bb164731d822efafa6c89c7bce7! Rakefile 100644 blob 644eda506db859e011ccbca5a06421ee76782ac7! init.rb 040000 tree 523fa41bd27fa29a00afb0bef6a10fde75aef501! lib>git cat-file -p f2eb1e
  • 21. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  • 22. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  • 23. 3 Commits
  • 24. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  • 25. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  • 26. Commit Content
  • 27. Commit Content tree f2eb1e549e7e0d9cd5b7a580e63e9ce79d5a03ae author Jeff Kunkle <jkunkle@nearinfinity.com> 1261341813 -0500 committer Jeff Kunkle <jkunkle@nearinfinity.com> 1261341813 -0500 initial commit first commit>git cat-file -p 3848fa
  • 28. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  • 29. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  • 30. Commit Contenttree ac451e549e7e0d9cd5b7a580e63e9ce79d5b45a1parent 3848fa7e91490a99b77590ff1385c4b3eebb3de3author Jeff Kunkle <jkunkle@nearinfinity.com> 1261351813 -0500committer Jeff Kunkle <jkunkle@nearinfinity.com> 1261351813 -0500second commit next commit
  • 31. 4 Tags
  • 32. ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  • 33. ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa tag : e9eff3>git tag -a v1.0
  • 34. Tag Content
  • 35. Tag Content object 3848fa7e91490a99b77590ff1385c4b3eebb3de3 type commit tag v1.0 tagger Jeff Kunkle <jkunkle@ni.com> Tue Dec 29 21:02:04 2009 -0500 version 1.0>git cat-file -p v1.0
  • 36. ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa tag : e9eff3>git tag -a v1.0
  • 37. ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa tag : e9eff3>git tag -a v1.0
  • 38. References
  • 39. Basic Data Model tag commit tree blob
  • 40. Basic Data Model tag commit Immutable Git Objects tree blob
  • 41. Basic Data Model tagbranch commit Immutable Git Objects tree blob
  • 42. Basic Data Model tagbranch commit Immutable Git Objects tree blob
  • 43. Basic Data ModelHEAD tagbranch commit Immutable Git Objects tree blob
  • 44. Basic Data Model HEAD tag branch commit Immutable Git Objects Mutable treeReferences blob
  • 45. Working Directory ./ Rakefile init.rb lib grant.rb
  • 46. HEADbranch tagcommit tree blob tree blob blob
  • 47. HEAD HEAD branch tag branch commit commit tree blob tree tree blob tree blob blob>git commit -a lib/grant.rb
  • 48. HEAD HEAD HEAD branch tag branch branch commit commit commit tree blob tree tree blob tree blob tree blob blob blob>git commit -a Rakefile init.rb
  • 49. Branches
  • 50. branch branchcommit tree C1 blob
  • 51. masterC C
  • 52. master C C idea>git checkout -b idea
  • 53. master C C C idea>git commit
  • 54. master C C C idea>git checkout master
  • 55. master C C C C idea>git commit
  • 56. bug master C C C C idea>git checkout -b bug
  • 57. bug master C C C C C idea>git commit
  • 58. bug master C C C C C idea>git commit checkout master
  • 59. bug master C C C C C idea>git commitbug merge
  • 60. bug master C C C C C C idea>git commitbug merge
  • 61. bug master C C C C C C idea>git commitbug bug branch merge -d
  • 62. bug master C C C C C C idea>git commitbugidea checkout branch merge -d bug
  • 63. bug master C C C C C C C idea>git commitbugidea checkout branch merge -d bug
  • 64. bug master C C C C C C C C idea>git commitbugidea checkout branch merge -d bug
  • 65. bug master C C C C C C C C idea>git commitbugidea checkout bug branch merge -dmaster
  • 66. bug master C C C C C C C C idea>git commitbugidea checkout branch -dmaster merge ideabug
  • 67. bug master C C C C C C C C C idea>git commitbugidea checkout branch -dmaster merge ideabug
  • 68. bug master C C C C C C C C C idea>git commitbugidea checkout idea branch -dmaster merge ideabug
  • 69. Recommendations
  • 70. Starting new project?
  • 71. Starting new project? Use Git
  • 72. Using SVN or CVS?
  • 73. Using SVN or CVS? Switch to Git
  • 74. Using Team Studio?
  • 75. Using Team Studio? Maybe switch to Git
  • 76. Using MKS?
  • 77. Using MKS? Switch to Git or CVS, or Subversion, or anything else
  • 78. ReferencesGood Better Best *most diagrams in this presentation are based on Git internals

×