Re: removing files from history but not filesystem
- From
- Christof Krüger <git@christof-krueger.de>
- Date
- Jun 28, 2011, 07:04 UTC
- Message-ID
- <218bf1d3b2bf197a5f56d542c6a91960.squirrel@mail.localhost.li>
- In-Reply-To
- <CFCCFA00-B4BF-4A88-88A5-2F588630F7BB@uab.edu>
Hi,
> $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch > */one.txt' HEAD
The following should work:
git branch temp git filter-branch --index-filter 'git rm --cached --ignore-unmatch foo' temp git reset temp
This creates branch "temp" pointing to the same commit as "master". Then you filter-branch the "temp" branch. This leaves file "foo" in your working directory intact, as your current branch is actually "master". The third step resets your current "branch" to the commit pointed by the rewritten branch "temp". The default for git reset is --mixed which according to the man page leaves the working tree alone.
Regards, Chris