Removing large files when using git-svn to migrate repositories

Posted in: ,

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!

Discover more from Jonathan Desrosiers

Subscribe to get the latest posts sent to your email.

Leave a Reply

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

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)