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

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.

  • How do I install git-imerge on OS X?
  • How to mock a post commit hook in github, for a repo that is not owned
  • How to delete the old history after running git filter-branch?
  • Prevent pushes to git containing tabs in certain files (e.g. *.cpp, *.h, CMakeLists.txt)
  • How do I reuse an existing branch name as a new branch?
  • Git gvim diff can't show difference
  • 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.

  • How to easily Git commit in Eclipse Neon
  • Pull only unchanged files in Git
  • how to use git from another directory?
  • difference between “git checkout - . ” and “git checkout — .”
  • Why did Git create a merge commit with no file changes?
  • How do you set up Hudson to work with Git?
  • One Solution collect form web for “Git force push to github rejected for large file that is deleted and no longer tracked”

    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.

    Git Baby is a git and github fan, let's start git clone.