Git's fsck
doc talks about "dangling" objects, while the gc
doc talks only about "loose objects". There's a strict split.
But while skimming a few related SO posts, the terms seem to be used interchangeably. In the Git Book v2 and Git's source code as well:
(main) $ git checkout v2.33.0
(225bc32) $ rg 'dangling (object|commit|blob|tag|tree)' | wc -l
31
(225bc32) $ rg 'loose (object|commit|blob|tag|tree)' | wc -l
117
Lastly, both commands are often used in sequence, and it seems clear to me from their behavior that they target the same things.
Thus, "dangling" and "loose" are just 2 similar terms for the same concept. Is this summary correct?
Or is "loose objects" rather a category, while "dangling" is reserved intentionally for the specific types of objects?
Loose objects are the simpler format. It is simply the compressed data stored in a single file on disk. Every object written to a seperate file.
Objects that are stored above are referred to as Loose objects. When you start up with your repo, you mostly have loose objects. As the number goes higher, it becomes inefficient and they will be stored in a pack file. Such objects are called packed objects.
Dangling blob = A change that made it to the staging area/index, but never got committed. One thing that is amazing with Git is that once it gets added to the staging area, you can always get it back because these blobs behave like commits in that they have a hash too!!
Loose object can be dangling, packs can contain dangling objects. So these concepts are orthogonal. But you can create a reference (branch, tag) which will reference a dangling commit and it will stop "dangle".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With