Removing large files when using git-svn to migrate repositories


Today I was migrating SVN repositories over to GIT using BU’s svn2git utility. I came across one repository that GitHub would not allow me to push because it contained a file that was over 100MB.

After some investigation, I realized that the file it specified was only 25KB. However, at some point in its history it was over 100MB, Because I was pushing the entire commit history for that repository, it was rejecting everything.

The solution is to remove the file entirely from the repository’s history. It took some trial and error for me to find something that worked for me because most snippets relied on history already existing in the origin repository. Here is what worked for me:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD

Hope this helps someone!

,

Leave a Reply

Your email address will not be published. Required fields are marked *