[arch-general] git software: howto remove files from history and its objects

郑文辉(Techlive Zheng) techlivezheng at gmail.com
Mon Mar 12 09:28:13 EDT 2012


2012/3/12 Cédric Girard <girard.cedric at gmail.com>:
> On Mon, Mar 12, 2012 at 1:17 PM, F. Gr. <frgroccia at gmail.com> wrote:
>
>> Now I want to remove some files from history and
>> the objects in my repository. Are these the right commands?
>>
>> git filter-branch -d /dir1/subdir/ --index-filter 'git rm --cached -f
>> --ignore-unmatch' -- --all
>> rm -rf /git_repo/.git/refs/remotes/origin
>> git reflog expire --expire=0 --all
>> git gc --aggressive --prune=0
>>
>
>
> Seems OK.
> Just to be sure, start by doing a "git clone git_repo new_repo" and work on
> "new_repo". This way you could always go back from "git_repo" if something
> goes wrong.
>
> You may need to do a "git filter-branch --prune-empty" at the end to remove
> empty commits.
>
> --
> Cédric Girard

If you want tags get updated, plus `--tag-name-filter cat`.


More information about the arch-general mailing list