What you need to understand why this is failing and why the duplicate that phd linked is a duplicate, is to realize that git push
does not push files. What git push
pushes are commits. Commits contain files—each commit is a complete snapshot of all files—so this means that at least one of the commits you are pushing has the large file. When you go to remove the file from the current commit, it's not there, so that means that at least one of the commits you are pushing doesn't have the file. This is not self contradictory: you are pushing at least two commits, and at least one has the big file, while the last one does not have the big file.
Since git push
pushes commits (and files just come along for the ride), you must change which commits you push. You do this by replacing your previous history—your previous series of commits that you added—with a new, different history: a new, different series of commits you have added. There are many ways to do that.
To see which commits git push
will push, run git fetch
first (so that your repository has all the commits that the upstream repository has), then run git log HEAD@{upstream}..HEAD
.