Git force push to github rejected for large file that is deleted and no longer tracked

Taaam

So I'm fairly new to git and I've gotten in a bit of a pickle.

I have many new changes to my local copy that conflict with my github repo (however my local copy is correct and I'd like to just overwrite the remote repo). The local and remote copy have diverged by 2 and 3 commits.

I also accidentally added a few very large csv files to my local commit and now I am unable to push to the remote repo with git push -f because github rejects the large files.

Now I deleted the files and removed them from the commit with git rm --cached "filename.csv" and git commit --amend -CHEAD and they are no longer in the commit as far as I can tell from git ls-files | grep "*.csv" which returns blank.

However when I try to use git push -f now after they are no longer tracked, github still detects them and rejects my push because they are too large although they are no longer on the filesystem or in the commit.

How can I push the local copy to overwrite the remote and get the push to realize I no longer have the large files?

Thanks in advance for any and all git advice... it can be a bit confusing for a newbie.

Daniel

Sounds like you have committed the large file, then made another commit that deletes the large file. That means that the large file is still in one or more earlier commits. When you push to GitHub, you're pushing the whole repository, with all commits (including any that have the large file). GitHub is actually rejecting one of the older commits because of the large file.

The reason you can't see the file with git ls-files is that it only lists the files in the current index (the last commit, and changes your're about to commit) and working tree (the current state of the files on disk), not all files in the repository's history.

To fix the problem, you can follow the steps on How to remove/delete a large file from commit history in Git repository?. That way you can make it as though you never committed the file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related