{"thread":{"id":"19757","subject":"Confused about `git gc`","startedAt":"2009-06-09T08:28:39Z","lastAt":"2009-06-09T11:18:51Z","messageCount":3,"participants":["Yakup Akbay","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115896","messageId":"4A2E1D37.9010909@ubicom.com","threadId":"19757","inReplyTo":null,"subject":"Confused about `git gc`","fromName":"Yakup Akbay","fromEmail":"yakbay@ubicom.com","sentAt":"2009-06-09T08:28:39Z","receivedAt":"2009-06-09T08:28:39Z","isPatch":false,"sender":{"key":"yakbay@ubicom.com","avatar":"https://gravatar.com/avatar/b1a445348437a895f93c412e183919a84c8b1298747b5e6f285b233225a274cf?d=mp&s=160"},"body":"Looks like I didn't quite understand the actual role of `git gc`. I just \nthought that `git gc` would remove all unreferenced objects during the \nunpack-pack process. However, I'm not seeing the result what I was \nexpecting from `git gc`.\n\nI'm adding an object into the database, which is ignored by git. Then I \nexpect the object to be removed after `git gc`. But, it's still there.\n\nPlease follow:\n\n$ echo \"/ignored_file\" > .gitignore\n$ echo \"This file is ignored by git. I'm sure that this content has \nnever been existed in the repository before.\" > ignored_file\n$ git hash-object -w ignored_file\n39cd40a92c0a92bbcbd74ec6879b4936212beebd\n$ ls .git/objects/\n07  39  9f  b9  d0  fa  info  pack\n$ ls .git/objects/39/\ncd40a92c0a92bbcbd74ec6879b4936212beebd\n$ git gc\nCounting objects: 319, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (147/147), done.\nWriting objects: 100% (319/319), done.\nTotal 319 (delta 124), reused 319 (delta 124)\n$ ls .git/objects/39/\ncd40a92c0a92bbcbd74ec6879b4936212beebd\n\n\nAs you see, 39cd40a92c0a92bbcbd74ec6879b4936212beebd is still there. \nShouldn't it be removed by `git gc`?\n\nWhat am I overlooking?\n\n\nRegards,\nYakup\n"},{"id":"115897","messageId":"m3ljo14r61.fsf@localhost.localdomain","threadId":"19757","inReplyTo":"4A2E1D37.9010909@ubicom.com","subject":"Re: Confused about `git gc`","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-09T10:45:40Z","receivedAt":"2009-06-09T10:45:40Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Yakup Akbay <yakbay@ubicom.com> writes:\n\n> Looks like I didn't quite understand the actual role of `git gc`. I\n> just thought that `git gc` would remove all unreferenced objects\n> during the unpack-pack process. However, I'm not seeing the result\n> what I was expecting from `git gc`.\n> \n> I'm adding an object into the database, which is ignored by git. Then\n> I expect the object to be removed after `git gc`. But, it's still\n> there.\n\n[...]\n> What am I overlooking?\n\nYou are probably overlooking the safety introduced to \"git gc\" to make\nit safer against concurrently run git operations, namely the fact that\nit would not remove new loose objects (it would remove loose objects\nonly when they are old enough).\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"115898","messageId":"4A2E451B.3080600@ubicom.com","threadId":"19757","inReplyTo":"m3ljo14r61.fsf@localhost.localdomain","subject":"Re: Confused about `git gc`","fromName":"Yakup Akbay","fromEmail":"yakbay@ubicom.com","sentAt":"2009-06-09T11:18:51Z","receivedAt":"2009-06-09T11:18:51Z","isPatch":false,"sender":{"key":"yakbay@ubicom.com","avatar":"https://gravatar.com/avatar/b1a445348437a895f93c412e183919a84c8b1298747b5e6f285b233225a274cf?d=mp&s=160"},"body":"Jakub Narebski wrote:\n> Yakup Akbay <yakbay@ubicom.com> writes:\n>\n>   \n>> Looks like I didn't quite understand the actual role of `git gc`. I\n>> just thought that `git gc` would remove all unreferenced objects\n>> during the unpack-pack process. However, I'm not seeing the result\n>> what I was expecting from `git gc`.\n>>\n>> I'm adding an object into the database, which is ignored by git. Then\n>> I expect the object to be removed after `git gc`. But, it's still\n>> there.\n>>     \n>\n> [...]\n>   \n>> What am I overlooking?\n>>     \n>\n> You are probably overlooking the safety introduced to \"git gc\" to make\n> it safer against concurrently run git operations, namely the fact that\n> it would not remove new loose objects (it would remove loose objects\n> only when they are old enough).\n>\n>   \nHmm, I see.\n\n    git gc --prune=<date>\n\nhelped me remove all loose objects.\n\n\nThanks,\nYakup\n"}]}