How to avoid pushing of the big sized files after git commit and git revert?

Viewed 18

I had few big files(over 100 MB) that I unknowingly committed. Naturally git could not push the same and returned with an error message. Then I tried the following steps to commit without the big files and push the same to the remote repository but I am not able to do so. In the git log, I have the following commits or the events as stated below -

Commit a :- Initial commit *//This is the commit done earlier without the big files.*
Commit b :- Updated commit *//This is the commit done after further development of the application with the big files*
Commit c :- revert commit b *// I reverted the commit realising that I cannot commit along with the big files as it is showing an error*
Commit d :- Revert "Revert commit c" *// I had to revert the previous commit realising that the after doing "revert commit b" I could get rid of the big files but also lost other developments on the application which I need.* 
Commit e :- Commit after deleting the big files *// This time I deleted the big files and committed the updated application again so that it works*

However, now when I try to push it is again showing the same old error with the large files and the file size limit. How can I push without the big files? I tried doing -- git rm --cached bigfile.json // but this is showing the error message that "fatal: pathspec 'bigfile.json' did not match any files"

1 Answers

You can :

# return to where you were at Commit b :
git reset --hard <Commit b>

# remove the big files from git's index :
git rm --cached that/big/file that/other/big/file
# with '--cached' you will still have the files on disk
# if you don't even need to keep said file on disk :
git rm big/file/to/delete

# now update Commit b to *not* contain these big files :
git commit --amend
Related