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

Paul Gideon Dann pdgiddie at gmail.com
Mon Mar 12 08:26:32 EDT 2012


On Monday 12 Mar 2012 13:17:11 F. Gr. wrote:
> Hi,
> I'm a new user of git software. I imported a mercurial repository to
> a git repository. 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
> 
> then (perhaps :-) I can push to my remote repository. I haven't tried
> the above commands yet because I don't want to break my repository.

Don't forget you can easily copy your repository.  Make a complete backup (cp 
-a is fine), and try your commands.  If it doesn't work, just try again on a 
fresh repository until you get it right :)

If you get stuck, ask again here.  It'll be easier to help you if you actually 
run into a specific problem, and have some example output for us to look at.

Paul


More information about the arch-general mailing list