Your SlideShare is downloading. ×
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
Git Internals
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

Git Internals

3,354

Published on

An explanation about the organization of a Git repo, the type of objects it contains inside and the relations between them.

An explanation about the organization of a Git repo, the type of objects it contains inside and the relations between them.

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,354
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
78
Comments
0
Likes
1
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. GIT Internals Pedro Melo <{mailto,xmpp}:melo@simplicidade.org>
  • 2. A short GIT History • 2002 Apr 2005: The BitKeeper Wars • Apr 2005: Episode IV - A New Hope • July 2005: Hamano is the new maintainer • Late 2008: GitHub hits the spotlight “I’m an egotistical bastard, and I name all my projects after myself. First Linux, now git.” – Linus
  • 3. on A short GIT History Person al take • 2002 Apr 2005: The BitKeeper Wars • Apr 2005: Episode IV - A New Hope • July 2005: Hamano is the new maintainer • Late 2008: GitHub hits the spotlight “I’m an egotistical bastard, and I name all my projects after myself. First Linux, now git.” – Linus
  • 4. GIT rules (without !!) • Track content, not changes • Simple repository • Complex software • Its easier to update the software, complex to update all the repos so far Git Mantra: http://bit.ly/git-phylosophy
  • 5. In other words, I'm right. I'm always right, but sometimes I'm more right than other times. And dammit, when I say "files don't matter", I'm really really Right(tm). Linus
  • 6. Strong Points • Non-Linear development • Distributed Development • Centralized development is a subcase • Efficiency • Toolkit Design
  • 7. Objects • Git repositories store objects • Stored in the Object Database • Inside the Git directory • .git at the root of your project • Four major object types • Objects are compressed for storage (zlib) • SHA1 of header+content ID
  • 8. The Blob • Files are stored as blobs • Only content, no metadata
  • 9. Meet the blob blob [content_size]0 Your content goes here after the header I like pizza with apples
  • 10. The tree • Trees store directories • Mode, type, pointer and name • Recursive, trees can contain trees • Stored as a simple text file
  • 11. Meet the tree tree [content_size]0 100644 blob b5f21a README 100644 blob afe433 Makefile.PL 040000 tree a42cd0 lib
  • 12. The commit • The object that makes history • Pointer to a tree and the parent(s) commits if any • Author, committer and commit message
  • 13. Meet the commit... commit [content_size]0 tree 23edfc author Pedro Melo <melo@mini.me> 1243036800 committer Pedro Melo <melo@mini.me> 1243036800 commit without a parent usually called first commit
  • 14. ...and its child the other commit commit [content_size]0 tree fde45c parent 3454df author Pedro Melo <melo@mini.me> 1243036932 committer Pedro Melo <melo@mini.me> 1243036932 and we fixed that nasty bug after all, they do tend to crop up
  • 15. The tag • A name for a particular commit • Can contain a message • Optionally GPG signed • Allows for cryptographically secure releases
  • 16. Meet the tag tag [content_size]0 object 123fec type commit tag v1 tagger Pedro Melo <melo@mini.me> 1243037423 made it to 1.0!
  • 17. Git Data Model Recap • Immutable objects • A file per object • Repacked into object packs for efficiency • Organized as a directed acyclic graph
  • 18. proj/ Makefile.PL lib/ Cool.pm
  • 19. proj/ Makefile.PL lib/ Cool.pm
  • 20. proj/ Makefile.PL lib/ Cool.pm Cool.pm
  • 21. proj/ Makefile.PL lib/ Cool.pm Cool.pm
  • 22. proj/ Makefile.PL lib/ Cool.pm Makefile.PL lib/ Cool.pm
  • 23. proj/ Makefile.PL lib/ Cool.pm Makefile.PL lib/ Cool.pm
  • 24. proj/ Makefile.PL lib/ Cool.pm Makefile.PL lib/ Cool.pm
  • 25. proj/ Makefile.PL lib/ Cool.pm Makefile.PL lib/ Cool.pm
  • 26. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL lib/ lib/ Cool.pm
  • 27. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL lib/ lib/ Cool.pm
  • 28. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL lib/ lib/ Cool.pm
  • 29. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL lib/ lib/ Cool.pm Cool.pm
  • 30. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL Makefile.PL lib/ lib/ lib/ Cool.pm Cool.pm
  • 31. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL Makefile.PL lib/ lib/ lib/ Cool.pm Cool.pm
  • 32. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL Makefile.PL lib/ lib/ lib/ Cool.pm Cool.pm
  • 33. References • “Names” for commits • Mutable, they point to a specific commit and move to a new one after each commit Name • A branch is a reference, a name to a commit • Special HEAD reference: points to a reference
  • 34. proj/ Makefile.PL lib/ Cool.pm Makefile.PL Makefile.PL Makefile.PL lib/ lib/ lib/ Cool.pm Cool.pm
  • 35. master HEAD
  • 36. master HEAD
  • 37. master HEAD test
  • 38. master test HEAD
  • 39. master test HEAD
  • 40. master HEAD test
  • 41. test master HEAD
  • 42. test master Merge
  • 43. test Merge master
  • 44. test master Rebase
  • 45. master Rebase test
  • 46. master Rebase test
  • 47. Rebase + Merge master test
  • 48. Rebase + Merge master test
  • 49. Non-SCM uses for Git • Leverage strengths • immutable • over network pulls only missing objects • fast checkout (compare to copy, less to read) • easy rollback
  • 50. Beware of weak points • Always stores full copy of files • not good for backups of DB dumps • Full history more disk space • this might chance as “shallow clones” gain funcionality...
  • 51. Content distribution • Updates done in a master, central repository • Hierarchy of slave repositories • Fast sync between repositories, fast checkout • Can be automated with hooks • Useful if you have lots of static files, faster than rsync
  • 52. Read-only filesystem • Design web server that fetch objects directly from the object database • Compact storage, efficient retrieval • Packs of objects also very VM friendly, mmap ready • Some solutions already available OSS
  • 53. Wiki/Ticketing backend • Use git repository as storage for wiki or ticketing systems • Good match for distributed developement • Several solutions already available OSS • ... but similar to SCM usages
  • 54. That’s all folks! • I’ll be around #codebits, feel free to ask me stuff • If you want a git as a SCM demo, lets get organized and I’ll do a impromptu presentation, or even private lapdan^H^H^H^H^Hdemos • After #codebits <{mailto,xmpp}:melo@simplicidade.org
  • 55. About Git http://git-scm.com/ Git Internals: http://peepcode.com/products/git-internals-pdf Git book: http://progit.org/ About Me http://simplicidade.org/notes/ @pedromelo {mailto,xmpp}:melo@simplicidade.org skype:melopt http://github.com/melo http://www.slideshare.net/melopt

×