Git is not very complicated, but flexible. Sometimes this flexibility leads to funny consequences. For example, look at this commit on GitHub. It looks like a normal commit, but if you clone this repository for yourself, you will not find such a commit in it. Because it is a lost commit, better known as git loose object or orphaned commit. Under the cut - a little about the insides of Git, where it comes from and what to do if you come across it.echo 'test content' | git hash-object -w --stdin This architectural feature gave rise to the hazy saying that Git tracks renaming by file content. When renaming, the “commit” object will contain a link to the “file contents” object, but if the contents have not changed, then this will be a link to the object already in the repository.
When a developer creates a commit, Git places a single commit description object and a handful of objects in the repository that describe the file structure and file contents. Thus, “commits” are interconnected Git objects in a key-value store.By default, Git stores the contents of files entirely: if we changed the line in a 100-kilobyte source, then an object with all 100 kilobytes compressed with zlib will be added to the storage. So that the repository does not swell too much, a garbage collector is provided in Git, which is started when the push command is executed, and the objects are repackaged into a pack file that contains the difference between the source file and the next revision (diff).
In some cases, commit may not be needed. For example, the developer made a commit foo, and then rolled back the change using the reset command. Git is designed in such a way that it doesn’t remove commits right away, giving the developer the ability to “turn back” even the most destructive actions. The special command reflog allows you to view the activity log, which contains links to all changes to the repository.
I think you already guess. The specified commit was unnecessary: ​​most likely, the author made a rebase. But GitHub shows the contents of the server repository, from which the push command is never executed. And the garbage collector, most likely, also no one calls. At the same time, when cloning such a repository, Git sends only those commits to which there are links over the network, and “lost commits”, better known as loose objects, remain lying dead weight on the server side.Source: https://habr.com/ru/post/261743/
All Articles