gitgithubgithub-actionsgithub-for-mac

Not Able to Push to Github Due to Large Files


I am using Terminal on a Mac and trying to push a repo to Github, but when I push it says I have a file that is too large, giving the following error:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 37, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (27/27), 20.81 MiB | 498.00 KiB/s, done.
Total 27 (delta 15), reused 1 (delta 0)
remote: Resolving deltas: 100% (15/15), completed with 4 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: eee806fc05f90f1c129268e1958803a84feaabdf6910968f26094b8a1fbf8976
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File results/.nfs000000070d2c32a90000019c is 10490.42 MB; this exceeds GitHub's file size limit of 100.00 MB
To git@github.com:CMDA3634-FALL2020/cmda3634-fa20-proj03-samrizz4.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:CMDA3634-FALL2020/cmda3634-fa20-proj03-samrizz4.git'

The file was previously called results/bigSim.txt, but after calling this line:

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch results/bigSim.txt'

It got renamed to results/.nfs000000070d2c32a90000019c. I tried to do use rm and git rm to remove the file but I get an error saying:

fatal: git rm: 'results/.nfs000000070d2c32a90000019c': Device or resource busy

And because of this, I have tried to fix the error and push a few times, so I have gotten this too:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.

To which I did git pull and it said there was an Automatic merge failed; fix conflicts and then commit the result., so I went and edited the file it said and saved, then did git add, git commit <that file> and git push, but I get the same big long first error that the file is too large.

I have also tried to undo my pushes with git reset --soft HEAD~1, but that did not get me back to my original since I have pushed more than once and am behind by about 3 pushes.

Is there a way to fix this?


Solution

  • I was able to figure it out, I used the following commands:

    git fetch origin
    git reset --hard origin
    

    And then,

    git status
    git log
    

    Which checked my commit history to know how many commits I needed to backtrack by.

    Then,

    git reset --soft HEAD~4
    

    Replace 4 with how many commits you need to go back by.

    And then I ran

    git status
    git log
    

    to confirm that everything worked, and it did. This now got me back to before I pushed the large file and am now able to push without it.