{"thread":{"id":"41038","subject":"Forcing git to pack objects","startedAt":"2015-12-19T01:03:39Z","lastAt":"2015-12-20T07:41:07Z","messageCount":3,"participants":["Edmundo Carmona Antoranz","Mikael Magnusson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"274737","messageId":"CAOc6etZePL=yvy=fVt9e=RmwdStJy6Kf621icYbYOER-NyMvXg@mail.gmail.com","threadId":"41038","inReplyTo":null,"subject":"Forcing git to pack objects","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-12-19T01:03:39Z","receivedAt":"2015-12-19T01:03:39Z","isPatch":false,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Hi!\n\nRecently I was running manually a git gc --prune command (wanted to\nshrink my 2.8G .git directory by getting rid of loose objects) and I\nended up running out of space on my HD. After freaking out a little\nbit (didn't know if the repo would end up in a 'stable' state), I\nended up freeing up some space and I again have a working repo...\n_but_ I noticed that basically _all_ objects on my repo are laying\naround in directories .git/objects/00 to ff (and taking a whole lot of\nspace... like the .git directory is now like 5 GBs). After running git\ngc manually again it ended up taking a lot of time and the objects are\nstill there. Also git svn sometimes gcs after fetching and it took to\nrun cause of the gc execution (ended up killing it) and the files are\nstill there. Is it possible to ask git to put all those objects in\n.pack files? Or did I mess something on my repo?\n\nJust in case, that's a repo I use at work that's working on a windows\nbox (git for windows 2.6.3).\n\nThanks in advance.\n"},{"id":"274766","messageId":"CAHYJk3Tzx29A+ZuOhXcxZThwZ98WmKC4aiwX32T=KA-7PTqs7g@mail.gmail.com","threadId":"41038","inReplyTo":"CAOc6etZePL=yvy=fVt9e=RmwdStJy6Kf621icYbYOER-NyMvXg@mail.gmail.com","subject":"Re: Forcing git to pack objects","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2015-12-20T02:25:20Z","receivedAt":"2015-12-20T02:25:20Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"On Sat, Dec 19, 2015 at 2:03 AM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> Hi!\n>\n> Recently I was running manually a git gc --prune command (wanted to\n> shrink my 2.8G .git directory by getting rid of loose objects) and I\n> ended up running out of space on my HD. After freaking out a little\n> bit (didn't know if the repo would end up in a 'stable' state), I\n> ended up freeing up some space and I again have a working repo...\n> _but_ I noticed that basically _all_ objects on my repo are laying\n> around in directories .git/objects/00 to ff (and taking a whole lot of\n> space... like the .git directory is now like 5 GBs). After running git\n> gc manually again it ended up taking a lot of time and the objects are\n> still there. Also git svn sometimes gcs after fetching and it took to\n> run cause of the gc execution (ended up killing it) and the files are\n> still there. Is it possible to ask git to put all those objects in\n> .pack files? Or did I mess something on my repo?\n>\n> Just in case, that's a repo I use at work that's working on a windows\n> box (git for windows 2.6.3).\n>\n> Thanks in advance.\n\ngit repack -d should do it.\n\n-- \nMikael Magnusson\n"},{"id":"274772","messageId":"20151220074106.GE30662@sigill.intra.peff.net","threadId":"41038","inReplyTo":"CAOc6etZePL=yvy=fVt9e=RmwdStJy6Kf621icYbYOER-NyMvXg@mail.gmail.com","subject":"Re: Forcing git to pack objects","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-12-20T07:41:07Z","receivedAt":"2015-12-20T07:41:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 18, 2015 at 07:03:39PM -0600, Edmundo Carmona Antoranz wrote:\n\n> Recently I was running manually a git gc --prune command (wanted to\n> shrink my 2.8G .git directory by getting rid of loose objects) and I\n> ended up running out of space on my HD. After freaking out a little\n> bit (didn't know if the repo would end up in a 'stable' state), I\n> ended up freeing up some space and I again have a working repo...\n> _but_ I noticed that basically _all_ objects on my repo are laying\n> around in directories .git/objects/00 to ff (and taking a whole lot of\n> space... like the .git directory is now like 5 GBs). After running git\n> gc manually again it ended up taking a lot of time and the objects are\n> still there. Also git svn sometimes gcs after fetching and it took to\n> run cause of the gc execution (ended up killing it) and the files are\n> still there. Is it possible to ask git to put all those objects in\n> .pack files? Or did I mess something on my repo?\n\nIt sounds like these objects aren't reachable from any of your refs.\nThat would explain:\n\n - why they don't get packed; we only pack reachable objects.\n\n   There's no easy way with \"git gc\" or \"git repack\" to pack unreachable\n   objects. If you drop down to the \"git pack-objects\" level, you can\n   manually convince it to do so.\n\n   I have a patch to add \"git repack -k\", which packs even unreachable\n   objects (we use this at GitHub, since our routine repository\n   maintenance never deletes objects). If people are interested, I can\n   clean it up and post it to the list.\n\n - why your repo grew during the gc; packed unreachable objects are\n   exploded into loose objects during a gc, so they can age and expire\n   on their own (we use filesystem mtimes to determine how old they\n   are).\n\n   Git is smart enough not to explode loose objects that it is just\n   going to prune in a moment.  But the default expiration time is 2\n   weeks, so there's a good chance it would want to keep some of them.\n\n   If you use \"git gc --prune=now\", that should prune everything\n   immediately (and this is safe, as long as you know there are no\n   simultaneous users of your local repository).\n\n-Peff\n"}]}