3

Git displayed "removing duplicate objects" after I merged a branch to another and noticed my .git/objects folder has significantly reduced (from 40.7 MB to 33.5 MB).
Isn't branch just supposed to be a pointer, so why git needs to delete some objects?
What actually happened there?
Is it simply git's natural behavior?

  • 3
    I'm not sure but this sounds like the "garbage collection" it does periodically, which can be invoked manually with git gc. – Ixrec Jun 18 '15 at 22:51
2

During garbage collection, git takes the objects from your .git/objects directory, and packs them into the packfile in .git/objects/pack. During this phase, it also compresses the files and takes advantage of the similarity between files to reduce their size. Typically the packfile will increase in size a lot less than the size of the objects that have been moved into it, as it is able to do inter-file optimisations.

Once these objects are in the packfile then there these objects are actually in your local repository twice, once as an object file, and once in the packfile. The "removing duplicate objects" phase, then removes these duplicates from your .git/objects directory, and so the size of the directory is decreased.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.