Re: purging unwanted history

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Geoff Russell <geoffrey.russell@...>
Cc: <git@...>
Date: Sunday, November 16, 2008 - 10:24 pm

On 2008.11.17 10:56:23 +1030, Geoff Russell wrote:

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.

HTH
Björn
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
purging unwanted history, Geoff Russell, (Sun Nov 16, 8:26 pm)
Re: purging unwanted history, Marcel M. Cary, (Tue Nov 18, 10:28 am)
Re: purging unwanted history, Björn, (Sun Nov 16, 10:24 pm)
Re: purging unwanted history, Björn, (Sun Nov 16, 10:27 pm)
Re: purging unwanted history, Geoff Russell, (Sun Nov 16, 11:03 pm)