Re: git filter-branch --subdirectory-filter, still a mistery
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Aug 7, 2008, 07:50 UTC
- Message-ID
- <200808070950.23754.trast@student.ethz.ch>
- In-Reply-To
- <200808061539.50268.J.Wielemaker@uva.nl>
Jan Wielemaker wrote: [...]
Show 5 quoted lines
> % git filter-branch --subdirectory-filter packages/chr HEAD > > This indeed creates a nice directory holding only the contents of > packages/chr. But, starting qgit I see that all commits, also those > that had absolutely nothing to do with this dir are still there.
The trick is to rewrite all refs, not just HEAD. I usually proceed as follows:
cp -a repo repo.old # just to keep a backup cd repo git filter-branch --subdirectory-filter somedir -- --all
The --all tells it to rewrite as many refs as possible. Note that the -- is required. Also note that refs/original/* will still point to the old commits, so they won't "just vanish". You may want to clone the repository or delete them manually once you are sure the filter-branch did the right thing.
- Thomas