0

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"

Jeet
  • 359
  • 1
  • 6
  • 24
  • 1
    Don't use revert as this doesn't remove the files from the repo. Does this help? https://stackoverflow.com/questions/60356194/accidentally-committed-a-large-file-to-local-git-now-i-have-to-remove-it-to-pus – evolutionxbox Sep 15 '22 at 08:05
  • @evolutionxbox- Thanks but how should I proceed ahead considering the git log above? – Jeet Sep 15 '22 at 08:07

1 Answers1

0

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
LeGEC
  • 46,477
  • 5
  • 57
  • 104