git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Grimm <koreth@midwinter.com>
To: John Wiegley <jwiegley@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Question about removing old objects
Date: Sat, 21 Apr 2007 16:29:06 -0700	[thread overview]
Message-ID: <462A9E42.3050409@midwinter.com> (raw)
In-Reply-To: <A2948362-ADC0-4F86-92BB-D942E9EF0AAC@gmail.com>

John Wiegley wrote:
> Hello, I am thinking of using git to track my home directory.  
> However, rather than keeping old history around forever, I'd like to 
> physically remove old objects after X days -- in essence, causing the 
> repository to appear as if it had begun life X days ago.  Is there a 
> git command to do this?

Not exactly, but you can fake it using shallow clones. Something like 
this, assuming you do one revision per day and want to keep 10 days 
around (if you commit at irregular intervals, you'll have to do some 
scanning to figure out how deep to make the clone):

# Go to the top level of your home-dir repo
cd $HOME
# Shallow clone the home-directory repo into a temporary one
git clone --depth 10 -n . .temp-repo
# Replace the home directory's repo with the shallow clone
rm -rf .git.old
mv .git .git.old
mv .temp-repo/.git .
# Since we did clone -n, there's nothing left in .temp-repo
rmdir .temp-repo
# Make the shallow clone cloneable so we can do this again tomorrow
rm -f .git/shallow

I haven't tried that exactly, but I think it should work. Of course, the 
final step removes a safety measure from the clone: you are technically 
not supposed to clone a shallow repo since it has an incomplete history 
and merges will probably fail horribly. But if, as it sounds like may be 
the case, you only ever have one copy of the repo anyway, I believe that 
should be harmless. If you're doing lots of branching and merging of 
your home directory then all bets are off.

A more experienced git user than me will probably tell you (and me) if 
I've suggested something stupid there, so you might want to wait for 
some replies to this message before you start relying on that procedure.

-Steve

  reply	other threads:[~2007-04-21 23:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-21 22:55 Question about removing old objects John Wiegley
2007-04-21 23:29 ` Steven Grimm [this message]
2007-04-22  0:15 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=462A9E42.3050409@midwinter.com \
    --to=koreth@midwinter.com \
    --cc=git@vger.kernel.org \
    --cc=jwiegley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).