On Wednesday, July 10, 2013 10:11:10 AM UTC+2, ironm...@gmail.com wrote:
> Hello everyone,
> I have a repo with a size of ca 4 gb and the history is longer than 10
> Now I want to truncate this history to the last 3 years.
> I tried some things but nothing works really.
> What would be the best approach to truncate the history?
> Do I need to remove all tags and branches beyond the 3 years mark?
> It would be nice if someone could get me a hint on how to do this magic.
Before you start deleting history to save space, you may want to first have
a look at wiping big old files from history, especially the ones that
aren't in use any more (i.e. they don't exist in HEAD).
For this purpose, try out the BFG Repo Cleaner:
Now, if you still want to remove history, you can use "grafting".
Conventionally, grafting is used to connect two commits together to form a
new path in the history, but you can also leave one graft-point out, and
the remaining one becomes the first ancestor in the repo.
First select the SHA you want to be the first commit in your new history (git
log --before "3 years" or something like that).
git clone --mirror myproject/ /tmp/experiment.git
echo SHA > info/grafts
# have a look around and see if history is ok, then set the graft in stone
by running filter branch through the history:
git filter-branch --tag-name-filter cat -- --all
git gc --prune=now
Note that I did a full backup (mirror) of the repository before rewriting.
Make sure you also do this, and keep the old repo in a safe place.
Afterwards, do a clone of /tmp/experiment.git and see if it looks like what
you want. Rinse and repeat if necessary.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/groups/opt_out.