martin36 martin36 - 3 months ago 42
Git Question

Old commit makes git unable to push

I tried to push a file which was above 100 mb and I got the error that you cannot push files that are above 100 mb in size. Then I changed in my file so that the size is now 15 mb, and recommited everything. The problem is that the old commit still exists, and when I try to push everything the old commit "blocks" the new one from pushing. I still get the same error as before with the size limit.

So, my question is whether there is any possibility to make git ignore this commit when pushing or can I remove it from the branch history?


You can reset your repository to the commit right before the big 100 mb commit with (this will drop all commits after that hash)

git reset --hard <sha1-commit-id>

Then recommit your 15 mb file.

Or you can do a interactive rebase and drop the commit (d) which keeps the other commits and reapply them

git rebase -i HEAD~N

while N is the number of commits you want to go backwards during rebase