{"thread":{"id":"7771","subject":"Question about removing old objects","startedAt":"2007-04-21T22:55:26Z","lastAt":"2007-04-22T00:15:44Z","messageCount":3,"participants":["John Wiegley","Steven Grimm","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"40073","messageId":"A2948362-ADC0-4F86-92BB-D942E9EF0AAC@gmail.com","threadId":"7771","inReplyTo":null,"subject":"Question about removing old objects","fromName":"John Wiegley","fromEmail":"jwiegley@gmail.com","sentAt":"2007-04-21T22:55:26Z","receivedAt":"2007-04-21T22:55:26Z","isPatch":false,"sender":{"key":"jwiegley@gmail.com","avatar":"https://gravatar.com/avatar/65ad91a7e7d1b6423bcb82a5bcfd91167f7064b752bd259141e9dc2d48fe76be?d=mp&s=160"},"body":"Hello, I am thinking of using git to track my home directory.   \nHowever, rather than keeping old history around forever, I'd like to  \nphysically remove old objects after X days -- in essence, causing the  \nrepository to appear as if it had begun life X days ago.  Is there a  \ngit command to do this?\n\nThanks, John\n"},{"id":"40074","messageId":"462A9E42.3050409@midwinter.com","threadId":"7771","inReplyTo":"A2948362-ADC0-4F86-92BB-D942E9EF0AAC@gmail.com","subject":"Re: Question about removing old objects","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-04-21T23:29:06Z","receivedAt":"2007-04-21T23:29:06Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"John Wiegley wrote:\n> Hello, I am thinking of using git to track my home directory.  \n> However, rather than keeping old history around forever, I'd like to \n> physically remove old objects after X days -- in essence, causing the \n> repository to appear as if it had begun life X days ago.  Is there a \n> git command to do this?\n\nNot exactly, but you can fake it using shallow clones. Something like \nthis, assuming you do one revision per day and want to keep 10 days \naround (if you commit at irregular intervals, you'll have to do some \nscanning to figure out how deep to make the clone):\n\n# Go to the top level of your home-dir repo\ncd $HOME\n# Shallow clone the home-directory repo into a temporary one\ngit clone --depth 10 -n . .temp-repo\n# Replace the home directory's repo with the shallow clone\nrm -rf .git.old\nmv .git .git.old\nmv .temp-repo/.git .\n# Since we did clone -n, there's nothing left in .temp-repo\nrmdir .temp-repo\n# Make the shallow clone cloneable so we can do this again tomorrow\nrm -f .git/shallow\n\nI haven't tried that exactly, but I think it should work. Of course, the \nfinal step removes a safety measure from the clone: you are technically \nnot supposed to clone a shallow repo since it has an incomplete history \nand merges will probably fail horribly. But if, as it sounds like may be \nthe case, you only ever have one copy of the repo anyway, I believe that \nshould be harmless. If you're doing lots of branching and merging of \nyour home directory then all bets are off.\n\nA more experienced git user than me will probably tell you (and me) if \nI've suggested something stupid there, so you might want to wait for \nsome replies to this message before you start relying on that procedure.\n\n-Steve\n"},{"id":"40076","messageId":"7vlkgls1qn.fsf@assigned-by-dhcp.cox.net","threadId":"7771","inReplyTo":"A2948362-ADC0-4F86-92BB-D942E9EF0AAC@gmail.com","subject":"Re: Question about removing old objects","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-22T00:15:44Z","receivedAt":"2007-04-22T00:15:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I think I've given a fairly detailed outline to do something\nlike that on the list a few months ago.  Ask the list archive.\n"}]}