Git from the Bottom Up – Blobs and Trees episode artwork

EPISODE · Aug 15, 2022 · 1H 42M

Git from the Bottom Up – Blobs and Trees

from Coding Blocks · host Allen Underwood, Michael Outlaw, Joe Zack

It's surprising how little we know about Git as we continue to dive into Git from the Bottom Up, while Michael confuses himself, Joe has low standards, and Allen tells a joke. The full show notes for this episode are available at https://www.codingblocks.net/episode191. News Thanks for all the great feedback on the last episode and for sticking with us! Directory Content Tracking Put simply, Git just keeps a snapshot of a directory's contents. Git represents your file contents in blobs (binary large object), in a structure similar to a Unix directory, called a tree. A blob is named by a SHA1 hashing of the size and contents of the file. This verifies that the blob contents will never change (given the same ID). The same contents will ALWAYS be represented by the same blob no matter where it appears, be it across commits, repositories, or even the Internet. If multiple trees reference the same blob, it's simply a hard link to the blob. As long as there's one link to a blob, it will continue to exist in the repository. A blob stores no metadata about its content. This is kept in the tree that contains the blob. Interesting tidbit about this: you could have any number of files that are all named differently but have the same content and size and they'd all point to the same blob. For example, even if one file were named abc.txt and another was named passwords.bin in separate directories, they'd point to the same blob. This allows for compact storage. Introducing the Blob This is worth following along and trying out. The author creates a file and then calculates the ID of the file using git hash-object filename. If you were to do the same thing on your system, assuming you used the same content as the author, you'd get the same hash ID, even if you name the file different than what they did. git cat-file -t hashID will show you the Git type of the object, which should be blob. git cat-file blob hashID will show you the contents of the file. The commands above are looking at the data at the blob level, not even taking into account which commit contained it, or which tree it was in. Git is all about blob management, as the blob is the fundamental data unit in Git. Blobs are Stored in Trees Remember there's no metadata in the blobs, and instead the blobs are just about the file's contents. Git maintains the structure of the files within the repository in a tree by attaching blobs as leaf nodes within a tree. git ls-tree HEAD will show the tree of the latest commit in the current directory. git rev-parse HEAD decodes the HEAD into the commit ID it references. git cat-file -t HEAD verifies the type for the alias HEAD (should be commit). git cat-file commit HEAD will show metadata about the commit including the hash ID of the tree, as well as author info, commit message, etc. To see that Git is maintaining its own set of information about the trees, commits and blobs, etc., use find .git/objects -type f and you'll see the same IDs that were shown in the output from the previous Git commands. How Trees are Made There's a notion of an index, which is what you use to initially create blobs out of files. If you just do a git add without a commit, assuming you are following along here (jwiegly.github.io), git log will fail because nothing has been committed to the repository. git ls-files --stage will show your blob being referenced by the index. At this point the file is not referenced by a tree or a commit, it's only in the .git/index file. git write-tree will take the contents of the index and write it to a tree, and the tree will have it's own hash ID. If you followed along with the link above, you'd have the same hash from the write-tree that we get. A tree containing the same blob and sub-trees will always have the same hash. The low-level write-tree command is used to take the contents of the index and write them into a new tree in preparation for a commit. git commit-tree takes a tree's hash ID and makes a commit that holds it. If you wanted that commit to reference a parent, you'd have to manually pass in the parent's commit ID with the -p argument. This commit ID will be different for everyone because it uses the name of the creator of the commit as well as the date when the commit is created to generate the hash ID. Now you have to overwrite the contents of .git/refs/heads/master with the latest commit hash ID. This tells Git that the branch named master should now reference the new commit. A safer way to do this, if you were doing this low-level stuff, is to use git update-ref refs/heads/master hashID. git symbolic-ref HEAD refs/heads/master then associates the working tree with the HEAD of master. What Have We Learned? Blobs are unique! Blobs are held by Trees, Trees are held by Commits. HEAD is a pointer to a particular commit. Commits usually have a parent, i.e. previous, commit. We've got a better understanding of the detached HEAD state. What a lot of those files mean in the .git directory. Resources We Like Things I wish everyone knew about Git (Part 1) (blog.plover.com) Git from the Bottom Up by John Wiegley (jwiegley.github.io) Why is Git … called Git? Git, Naming (Wikipedia) Git's README.md (GitHub) Tip of the Week Have you ever heard the tale of … the forbidden files in Windows? Windows has a list of names that you cannot use for files. Twitter user @foone has done the unthinkable and created a repository of these files. What would happen if you checked this repository out on Windows? Check out this convenient repository in Windows. (GitHub) Follow @foone's thread (Twitter) Thanks to Derek Chasse for this tip! When you use mvn dependency:tree, grep is your enemy. If you want to find out who is bringing in a specific dependency, you really need to use the -Dincludes flag. Thanks to @ttutko for this tip about redirecting output: kafkacat 2>&1 | grep "". If you're not familiar with that syntax, it just means pipe STDERR to STDOUT and then pipe that to grep. Thanks Volkmar Rigo for this one! Dangit, Git!? Git is hard: messing up is easy, and figuring out how to fix your mistakes is impossible. This website has some tips to get you out of a jam. (DangitGit.com) How to vacay … step 1 temporarily disable your work email (and silence Slack, Gchat, whateves). On iOS, go to Settings -> Mail -> Accounts -> Select your work account -> Turn off the Mail slider.

Episode metadata supplied by the publisher feed · Published Aug 15, 2022

NOW PLAYING

Git from the Bottom Up – Blobs and Trees

0:00 1:42:41

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

API Intersection Stoplight Building a successful API requires more than just coding. It starts with collaborative design, focuses on creating a great developer experience, and ends with getting your company on board, maintaining consistency, and maximizing your API’s profitability.In the API Intersection, you’ll learn from experienced API practitioners who transformed their organizations, and get tangible advice to build quality APIs with collaborative API-first design.Jason Harmon brings over a decade of industry-recognized REST API experience to discuss topics around API design, governance, identity/auth versioning, and more.They’ll answer listener questions, and discuss best practices on API design (definition, modeling, grammar), Governance (multi-team design, reviewing new API’s), Platform Transformation (culture, internal education, versioning) and more.They’ll also chat with experienced API practitioners from a wide array of industries to draw out practical takeaways and insights you can use.H Unshamed & Unchained: Carving Space For Self-Healing & Habit Transformation Danny Poelman Welcome to "Unshamed & Unchained: Carving Space For Self-Healing & Habit Transformation", the podcast where we break the chains of shame and societal expectations to create a safe space for self-healing, habit transformation, and personal growth. Hosted by a seasoned life coach, Danny Poelman DDS, with years of hands-on experience, this podcast is your guide to reclaiming your voice, embracing your story, and living life on your terms.In each episode, we dive deep into the topics that matter most to you—whether it's:-breaking free from unwanted habits like pornography-excessive people-pleasing-healing from past trauma-recovering from narcissistic abuse or religious/relational trauma-anxiety/depression-money mindset blocks-overcoming limiting beliefsWe’re not afraid to talk about the things that are often considered taboo, because we believe that through honest, unfiltered conversations, real transformation happens.You’ll hear real Khanyisa Keke TV Khanyisa Keke On Khanyisa Keke TV, developers can learn and improve their Android for Kotlin Development skills. On this podcast, programmers can learn Android for Kotlin coding from scratch, improve their existing programming skills, get tips, be kept up to date with all the latest happenings and get access to free resources. Powered by Firstory Hosting The Triathlon Mental Performance Podcast Neil Edge This podcast is for you if you are a Triathlete that is interested in learning about tools and strategies to overcome challenges and to utilize the power of your mind to race faster.I'm an experienced Triathlon Mental Performance Coach working with both Age Groupers and Pros.Episodes will cover the following and more.How to improve your mental toughnessRemoving the possibility of panic attacks in open water Removing the fear of fast descents on your bike -Removing mental blocks to improve your race times Completely remove performance anxiety (you don't have to just cope with it)4 weeks to race day - Strategies to  arrive at your a-race feeling calm and confident, with race day mental strategiesI will also talk about specific tools that you can use to ensure that you race faster.<b

Frequently Asked Questions

How long is this episode of Coding Blocks?

This episode is 1 hour and 42 minutes long.

When was this Coding Blocks episode published?

This episode was published on August 15, 2022.

What is this episode about?

It's surprising how little we know about Git as we continue to dive into Git from the Bottom Up, while Michael confuses himself, Joe has low standards, and Allen tells a joke. The full show notes for this episode are available...

Can I download this Coding Blocks episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!