Reputation: 1521
This is a follow up to my previous post here. I'm trying to remove a large file that I committed to git. Based on the suggestion given in my previous post, I tried
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch folder/Unconfirmed 866711.crdownload" --prune-empty --tag-name-filter cat -- --all
Following the above command, I tried to push all the changes
git push origin --force --all
However, I got the same error that was displayed before using filter-branch
remote: error: File folder/Unconfirmed 866711.crdownload is 486.30 MB; this exceeds GitHub's file size limit of 100.00 MB
Alternatively, I also tried
git add --all
git filter-branch -f --index-filter "git rm --cached --ignore-unmatch folder/Unconfirmed 866711.crdownload" HEAD
But, I get the following
Cannot rewrite branches: Your index contains uncommitted changes.
I'm not sure if I have missed any command or flags. Any suggestions?
Upvotes: 0
Views: 562
Reputation: 6742
Cannot rewrite branches: Your index contains uncommitted changes.
You have uncommitted changes in your working directory i.e changes staged for a commit (check git status
output) . Either commit those changes if you wish to or preserve those uncommitted changes by using stash and apply them once you have executed the filter-branch
command.
If you don't want the uncommitted changes, then you can perform a hard reset.
git reset --hard HEAD
stash
before filter-branch
Warning: If you run git filter-branch after stashing changes, you won't be able to retrieve your changes with other stash commands. Before running git filter-branch, we recommend unstashing any changes you've made.
So instead commit the changes if you want to preserve the uncommitted changes. Then proceed with the filter-branch
command.
filter-branch
command, is missing single quotes (to account for the space in the name of the file to be deleted)
git filter-branch -f --index-filter "git rm --cached --ignore-unmatch 'folder/Unconfirmed 866711.crdownload'" HEAD
Upvotes: 3