Reputation: 1580
I did a Mercurial -> git conversion using the fast-update utility. Everything went fine with the conversion. When I was attempting to push up to github, the push was rejected because some log files in the repo were too large. I removed them all using:
$> git branch
* master
new_admin_gui
$> git rm -r --cached logs
$> git rm -r --cached out
$> git rm -r --cached tmp
$> git commit -am "Removed files"
$> git checkout new_admin_gui
$> git rm -r --cached logs
$> git rm -r --cached out
$> git rm -r --cached tmp
$> git commit -am "Removed files"
When I do a git push
however, GitHub still rejects the push because
apparently the logs are still sitting in the repo somewhere. I can't git rm
-r --cached
any more because it tells me
fatal: pathspec 'logs' did not match any files
Obviously they are still somewhere in the repo, but I can't figure out where or how to get rid of them. There are only two branches so I don't think they are hiding out somewhere else.
Upvotes: 2
Views: 1365
Reputation: 24458
git rm --cached
removes the files you're trying to get rid of from future commits in your repository, but the log files are still in your repository's history. If they're too big to push out to GitHub, you'll need to nuke them from your history, too.
You can do this with the filter-branch
command, as described in GitHub's help documentation:
git filter-branch --force --index-filter \
'git rm -r --cached --ignore-unmatch logs/ out/ tmp/' \
--prune-empty --tag-name-filter cat -- --all
Upvotes: 2