Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Wird geladen in …3
×
1 von 78

Understanding Git Internals

17

Teilen

Herunterladen, um offline zu lesen

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.

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Ähnliche Hörbücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Understanding Git Internals

  1. 1. Git Understanding January 6, 2010 Jeff Kunkle
  2. 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 complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
  3. 3. Working Directory ./ Rakefile init.rb lib grant.rb
  4. 4. Working Directory ./ .git Rakefile init.rb lib grant.rb >git init
  5. 5. Working Directory ./ .git What’s in here? Rakefile init.rb lib grant.rb >git init
  6. 6. Objects
  7. 7. Git Objects header object_type [content size]0 content of the file can be text content can be binary can be whatever Zlib::Deflate
  8. 8. Git Objects header object_type [content size]0 content of the file can be text content can be binary can be whatever Zlib::Deflate 1 Blob 2 Tree 3 Commit 4 Tag
  9. 9. 1 Blobs
  10. 10. Working Directory Git Directory ./ Rakefile init.rb lib grant.rb
  11. 11. Working Directory Git Directory ./ Rakefile init.rb lib grant.rb >git add . >git commit -m “initial commit”
  12. 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. 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. 14. Blob Content
  15. 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. 16. 2 Trees
  17. 17. Working Directory Git Directory ./ Rakefile blob : 21a307 init.rb blob : 644eda lib grant.rb blob : a22a24
  18. 18. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  19. 19. Tree Content
  20. 20. Tree Content 100644 blob 21a30738954b6bb164731d822efafa6c89c7bce7! Rakefile 100644 blob 644eda506db859e011ccbca5a06421ee76782ac7! init.rb 040000 tree 523fa41bd27fa29a00afb0bef6a10fde75aef501! lib >git cat-file -p f2eb1e
  21. 21. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  22. 22. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  23. 23. 3 Commits
  24. 24. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24
  25. 25. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  26. 26. Commit Content
  27. 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. 28. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  29. 29. Working Directory Git Directory ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  30. 30. Commit Content tree ac451e549e7e0d9cd5b7a580e63e9ce79d5b45a1 parent 3848fa7e91490a99b77590ff1385c4b3eebb3de3 author Jeff Kunkle <jkunkle@nearinfinity.com> 1261351813 -0500 committer Jeff Kunkle <jkunkle@nearinfinity.com> 1261351813 -0500 second commit next commit
  31. 31. 4 Tags
  32. 32. ./ tree : f2eb1e Rakefile blob : 21a307 init.rb blob : 644eda lib tree : 523fa4 grant.rb blob : a22a24 commit : 3848fa
  33. 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. 34. Tag Content
  35. 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. 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. 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. 38. References
  39. 39. Basic Data Model tag commit tree blob
  40. 40. Basic Data Model tag commit Immutable Git Objects tree blob
  41. 41. Basic Data Model tag branch commit Immutable Git Objects tree blob
  42. 42. Basic Data Model tag branch commit Immutable Git Objects tree blob
  43. 43. Basic Data Model HEAD tag branch commit Immutable Git Objects tree blob
  44. 44. Basic Data Model HEAD tag branch commit Immutable Git Objects Mutable tree References blob
  45. 45. Working Directory ./ Rakefile init.rb lib grant.rb
  46. 46. HEAD branch tag commit tree blob tree blob blob
  47. 47. HEAD HEAD branch tag branch commit commit tree blob tree tree blob tree blob blob >git commit -a lib/grant.rb
  48. 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. 49. Branches
  50. 50. branch branch commit tree C1 blob
  51. 51. master C C
  52. 52. master C C idea >git checkout -b idea
  53. 53. master C C C idea >git commit
  54. 54. master C C C idea >git checkout master
  55. 55. master C C C C idea >git commit
  56. 56. bug master C C C C idea >git checkout -b bug
  57. 57. bug master C C C C C idea >git commit
  58. 58. bug master C C C C C idea >git commit checkout master
  59. 59. bug master C C C C C idea >git commitbug merge
  60. 60. bug master C C C C C C idea >git commitbug merge
  61. 61. bug master C C C C C C idea >git commitbug bug branch merge -d
  62. 62. bug master C C C C C C idea >git commitbugidea checkout branch merge -d bug
  63. 63. bug master C C C C C C C idea >git commitbugidea checkout branch merge -d bug
  64. 64. bug master C C C C C C C C idea >git commitbugidea checkout branch merge -d bug
  65. 65. bug master C C C C C C C C idea >git commitbugidea checkout bug branch merge -dmaster
  66. 66. bug master C C C C C C C C idea >git commitbugidea checkout branch -dmaster merge ideabug
  67. 67. bug master C C C C C C C C C idea >git commitbugidea checkout branch -dmaster merge ideabug
  68. 68. bug master C C C C C C C C C idea >git commitbugidea checkout idea branch -dmaster merge ideabug
  69. 69. Recommendations
  70. 70. Starting new project?
  71. 71. Starting new project? Use Git
  72. 72. Using SVN or CVS?
  73. 73. Using SVN or CVS? Switch to Git
  74. 74. Using Team Studio?
  75. 75. Using Team Studio? Maybe switch to Git
  76. 76. Using MKS?
  77. 77. Using MKS? Switch to Git or CVS, or Subversion, or anything else
  78. 78. References Good Better Best *most diagrams in this presentation are based on Git internals

×