Remove specific file from specifc commit when 'git filter-branch' fails

264 views Asked by At

I can't commit in my working directory anymore because there are some huge files in the repo that weren't included in gitignore, so they have been carried over and over in many commits/revisions.

I've followed the instructions at : http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history but the git filter-branch part fails with

Cannot rewrite branches: You have unstaged changes. Additionally, your index contains uncommitted changes.

Under these circumstances, how can I identify e.g. the largest file inside all commits, present or past, and then from a specific commit remove just the specific file?

1

There are 1 answers

0
eis On BEST ANSWER

Each commit is the state of the whole repo, so you have to rewrite all commits that come after that specific one as well. So no, you can't just edit that one commit.

The error message you see is about you having unstaged changes, so you need to for example stash them, or using another, clean checkout to do your filter-branching to be able to proceed.