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

Cédric Girard girard.cedric at gmail.com
Mon Mar 12 08:55:47 EDT 2012


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


More information about the arch-general mailing list