由于文件太大,无法推送到 Github

Not Able to Push to Github Due to Large Files

我在 Mac 上使用 Terminal 并尝试将 repo 推送到 Github,但是当我推送时它说我有一个太大的文件,并出现以下错误:

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'

该文件之前名为 results/bigSim.txt,但调用此行后:

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

它已重命名为 results/.nfs000000070d2c32a90000019c。我尝试使用 rmgit rm 删除文件,但我收到一条错误消息:

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

因此,我尝试修复错误并推送了几次,所以我也得到了这个:

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.

我做了git pull,它说有一个Automatic merge failed; fix conflicts and then commit the result.,所以我去编辑它说的文件并保存,然后做了git addgit commit <that file>git push,但我得到同样大的第一个错误,文件太大。

我也曾尝试用 git reset --soft HEAD~1 撤消我的推动,但这并没有让我回到原来的状态,因为我已经推动了不止一次并且落后了大约 3 次推动。

有办法解决这个问题吗?

我能够弄清楚,我使用了以下命令:

git fetch origin
git reset --hard origin

然后,

git status
git log

它检查了我的提交历史以了解我需要回溯多少次提交。

然后,

git reset --soft HEAD~4

将 4 替换为您需要返回的提交数。

然后我运行

git status
git log

确认一切正常,确实如此。这让我回到了推送大文件之前的状态,现在我可以在没有它的情况下推送。