100MB) file to my local repo. Two commits later I am trying ...">

Git remove file from all commits

I made a "small" mistake and added a "small" (> 100MB) file to my local repo.

Two commits later I am trying to push to a remote repo on github which has a 100MB limit.

I can remove the file from my current commit with git rm --cached

, but it is still in previous commits.

How do I remove a file from all commits? I tried this answer about git filter-branch but doesn't work for mine.

+3


source to share


2 answers


You can change the last 3 commits by interactive reinstallation.

git rebase -i HEAD~3

      



And change the commit to "edit".

See https://help.github.com/articles/about-git-rebase/

+1


source


I would soften to reset the last 3 commits. Then delete the "small" file. Then make all changes into 1 new commit.



It's not perfect I guess, but it solves the problem because you haven't done too many extra commits yet.

+1


source







All Articles