Re: purging unwanted history

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2008.11.17 03:24:12 +0100, Björn Steinbrink wrote:
> On 2008.11.17 10:56:23 +1030, Geoff Russell wrote:
> > I have a repository with 5 years worth of history, I only want to keep
> > 1 year, so I want to purge the first 4 years. As it happens, the
> > repository only has a single branch which should simplify the problem.
> 
> Use filter-branch to drop the parents on the first commit you want to
> keep, and then drop the old cruft.
> 
> Let's say $drop is the hash of the latest commit you want to drop. To
> keep things sane and simple, make sure the first commit you want to
> keep, ie. the child of $drop, is not a merge commit. Then you can use:
> 
> git filter-branch --parent-filter "sed -e 's/-p $drop//'" \
> 	--tag-name-filter cat -- \
> 	--all ^$drop
> 
> The above rewrites the parents of all commits that come "after" $drop.
> 
> Check the results with gitk.
> 
> 
> Then, to clean out all the old cruft.
> 
> First, the backup references from filter-branch:
> 
> git for-each-ref --format='%(refname)' refs/original | \
> 	while read ref
> 	do
> 		git update-ref -d "$ref"
> 	done
> 
> Then clean your reflogs:
> git reflog expire --expire=0 --all
> 
> And finally, repack and drop all the old unreachable objects:
> git repack -ad
> git prune # For objects that repack -ad might have left around
> 
> At that point, everything leading up to and including $drop should be
> gone.

Hm, on second thought, if you have tags referencing some of the old
history, they'll still be around, I think. Just delete those before you
start the rewriting.

And of course do the above with a copy of your repo. Just in case.

Björn
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux