Six3 Getting Git

  • Published on
    16-May-2015

  • View
    552

  • Download
    0

Embed Size (px)

DESCRIPTION

A talk I gave at Six3 on Git.

Transcript

  • 1. Getting Gitby Daniel Cox

2. Getting Gitby Daniel Cox(who is enormouslygrateful to Scott Chaconfor half of these slides) 3. THE MASTER PLAN What is Git? Understanding Git The Basics The Git Object Database History Inspection Branching Workflows Collaboration Advanced Stuff Troubleshooting Review Resources Questions 4. THE MASTER PLAN What is Git? Understanding Git The Basics The Git Object Database History Inspection Branching Workflows Collaboration Advanced Stuff Troubleshooting Review Resources Questions3 minutes15 hours2 minutes3 minutes20 minutes 5. What is Git? Git is a Version Control System Versioning Collaboration Other things Git is: A very simple content tracker A key/value object database with a VCS front-end A toolkit 6. What is Git?"Im an egotistical b[------], and I name all myprojects after myself. First Linux, now git.-- Linus Torvalds 7. the plumbing 8. the porcelain 9. What is Git?Something Git is not: Subversion Much faster for a slightly larger disk footprint(stores snapshots instead of deltas) Can do a bunch of stuff without a networkconnection Cheap branching and merging No .svn directory clutter And quite a bit more, since Git was not designedto be the latest evolution of rcs -> cvs -> svn -> 10. What is Git?What Git is on your hard drive.$> mkdir foobar$> cd foobar$> git init$> tree a .git 11. What is Git?.git HEAD config description hooks applypatch-msg.sample commit-msg.sample post-update.sample pre-applypatch.sample pre-commit.sample pre-rebase.sample prepare-commit-msg.sample update.sample info exclude objects info pack refs heads tags8 directories, 12 files$> tree a .git 12. What is Git?.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b22136034a95dd097a57d3dd cc 9fc8c4ea4df4f245103cbe80c35bfa2eb07e52 e6 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 info pack refs heads master tags14 directories, 20 files$> touch README$> git add .$> git commit minitial commit$> tree a .git 13. What is Git?.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b22136034a95dd097a57d3dd cc 9fc8c4ea4df4f245103cbe80c35bfa2eb07e52 e6 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 info pack refs heads master tags14 directories, 20 files$> touch README$> git add .$> git commit minitial commit$> tree a .git 14. What is Git?.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b22136034a95dd097a57d3dd cc 9fc8c4ea4df4f245103cbe80c35bfa2eb07e52 e6 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 info pack refs heads master tags14 directories, 20 files$> touch README$> git add .$> git commit minitial commit$> tree a .git 15. What is Git?.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b22136034a95dd097a57d3dd cc 9fc8c4ea4df4f245103cbe80c35bfa2eb07e52 e6 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 info pack refs heads master tags14 directories, 20 files$> touch README$> git add .$> git commit minitial commit$> tree a .git 16. Understanding Git The Basics The Git Object Database History Inspection Branching Workflows Collaboration Advanced Stuff Troubleshooting 17. The BasicsThe most basic tasks you need to be able to dowith Git are thus: git init git status git add git commit 18. The BasicsThe most basic tasks you need to be able to dowith Git are thus: git init git status git add git commit git tag 19. $> git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached ..." to unstage)## new file: README# new file: Rakefile# new file: lib/mylib.rb# 20. $> git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached ..." to unstage)## new file: README# new file: Rakefile# new file: lib/mylib.rb# 21. $> git tag first_commit$> 22. git init (work work work work) git status git add --all git status git commit (work work work) git status git add git status git commit git tag 23. Understanding Git The Basics The Git Object Database History inspection Branching workflows Collaboration Advanced Stuff Troubleshooting 24. The Git Object Database 25. The Git Object Database Key / Value SHA1 / Content 26. The Git Object Database Key / Value SHA1 / Content All objects go under the objects directoryunder .git.git HEAD config description hooks info exclude objects info pack refs heads tags8 directories, 12 files there 27. The Git Object Database.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b22136034a95dd097a57d3dd cc 9fc8c4ea4df4f245103cbe80c35bfa2eb07e52 e6 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 info pack refs heads master tags14 directories, 20 files 28. The Git Object Database Key / Value SHA1 / Content All objects go under the objects directoryunder .git There are only four kinds of objects that Gitstores during normal use: blobs (files) trees (directories) commits tags 29. The Git Object Databaseall git objects are stored as follows 30. The Git Object Databasecontent 31. The Git Object Databasenew_content = type + + content.size + 0+ contentcontent 32. The Git Object Databasenew_content = type + + content.size + 0+ contentsha = Digest::SHA1.hexdigest(new_content)content 33. The Git Object Databasenew_content = type + + content.size + 0+ contentsha = Digest::SHA1.hexdigest(new_content)content824aed035c0aa75d64c... 34. The Git Object Databasenew_content = type + + content.size + 0+ contentcompressed = zlib::deflate(new_content)sha = Digest::SHA1.hexdigest(new_content)content824aed035c0aa75d64c... 35. The Git Object Databasenew_content = type + + content.size + 0+ contentcompressed = zlib::deflate(new_content)sha = Digest::SHA1.hexdigest(new_content)content824aed035c0aa75d64c...path = .git/objects/82/4aed035c0aa75d64c... 36. The Git Object Databasenew_content = type + + content.size + 0+ contentcompressed = zlib::deflate(new_content)sha = Digest::SHA1.hexdigest(new_content)content824aed035c0aa75d64c...path = .git/objects/82/4aed035c0aa75d64c...File.open(path, w) {|f| f.write(compressed)} 37. The Git Object Databasenew_content = type + + content.size + 0+ contentcompressed = zlib::deflate(new_content)sha = Digest::SHA1.hexdigest(new_content)content824aed035c0aa75d64c...path = .git/objects/82/4aed035c0aa75d64c...File.open(path, w) {|f| f.write(compressed)}loose format 38. The Git Object Databasegit gc 39. The Git Object Databasegit gcsame file with minor differences 40. The Git Object Database.git/objects/f1/032eed02413a1145c...git gc.git/objects/45/b983be36b73c0788d....git/objects/04/fb8aee105e6e445e8....git/objects/63/874f37013c1740acd....git/objects/1d/c9cbcb76cbb80fce1....git/objects/82/4aed035c0aa75d64c...same file with minor differences 41. The Git Object Database.git/objects/f1/032eed02413a1145c...git gc.git/objects/45/b983be36b73c0788d....git/objects/04/fb8aee105e6e445e8....git/objects/63/874f37013c1740acd....git/objects/1d/c9cbcb76cbb80fce1....git/objects/82/4aed035c0aa75d64c....git/objects/pack/pack-999727..9f600.pack.git/objects/pack/pack-999727..9f600.idxsame file with minor differences 42. The Git Object Database.git/objects/f1/032eed02413a1145c...git gc.git/objects/45/b983be36b73c0788d....git/objects/04/fb8aee105e6e445e8....git/objects/63/874f37013c1740acd....git/objects/1d/c9cbcb76cbb80fce1....git/objects/82/4aed035c0aa75d64c....git/objects/pack/pack-999727..9f600.pack.git/objects/pack/pack-999727..9f600.idxsame file with minor differences 43. The Git Object Database.git/objects/f1/032eed02413a1145c...git gc.git/objects/45/b983be36b73c0788d....git/objects/04/fb8aee105e6e445e8....git/objects/63/874f37013c1740acd....git/objects/1d/c9cbcb76cbb80fce1....git/objects/82/4aed035c0aa75d64c....git/objects/pack/pack-999727..9f600.pack.git/objects/pack/pack-999727..9f600.idxsame file with minor differencespacked format 44. The Git Object DatabaseThere are only four types of Git objects 45. The Git Object Databaseblob 46. The Git Object Databaseblob tree 47. The Git Object Databasecommitblob tree 48. The Git Object Databasecommit tagblob tree 49. The Git Object Databaseblob 50. The Git Object Databaseblob 51. The Git Object Databaseblob 52. The Git Object Databasezlib::deflate 53. The Git Object Databasecontentzlib::deflate 54. The Git Object Databasecontentheaderzlib::deflate 55. The Git Object Databasecontentheadercompress zlib::deflate 56. The Git Object Databasecontentheadercompressobjectzlib::deflate 57. The Git Object Databasecommit tagblob tree 58. The Git Object Databasetree 59. The Git Object Databasetree 60. The Git Object Databasetree 61. The Git Object Databasezlib::deflate 62. The Git Object Databasefilenameinode infozlib::deflate 63. The Git Object Databaseblock pointertypemodezlib::deflate 64. The Git Object Databasecommit tagblob tree 65. The Git Object Databasecommit 66. The Git Object Databasecommit 67. The Git Object Databasezlib::deflate 68. The Git Object Databasezlib::deflate 69. The Git Object Databasezlib::deflate 70. The Git Object Databasezlib::deflate 71. The Git Object Databasezlib::deflate 72. The Git Object Database 73. The Git Object Databasecommit tagblob tree 74. The Git Object Databasetag 75. The Git Object Databasetag 76. The Git Object Databasezlib::deflate 77. The Git Object Databasezlib::deflate 78. The Git Object Databasezlib::deflate 79. The Git Object Databasezlib::deflate 80. The Git Object Databasezlib::deflate 81. The Git Object Database.git COMMIT_EDITMSG HEAD config description hooks index info exclude logs objects 54 3b9bebdc6bd5c4b2