我是 git 新手,并尝试将我的项目目录推送到 github。
以下是我遵循的步骤。
git init
git add .
git commit -m 'first commit'
git push <my repo address>
然后抛出以下错误。
Counting objects: 95, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (77/77), 920.61 MiB | 27.90 MiB/s, done.
Total 77 (delta 37), reused 1 (delta 0)
remote: Resolving deltas: 100% (37/37), completed with 10 local objects.
remote: warning: File images/log is 60.77 MB; this is larger than GitHub's recom mended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File S torage - https://git-lfs.github.com.
remote: error: Trace: c3704dac955cd6d24c55bfab021fbe2a
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File images/sql-push-image1.iso is 349.21 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File images/sql-push-image1.SPA.bin is 570.62 MB; this excee ds GitHub's file size limit of 100.00 MB
remote: error: File images/sql-push-image2.SPA.bin is 348.69 MB; t his exceeds GitHub's file size limit of 100.00 MB
remote: error: File images/sql-push-image1.ova is 349.49 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/mohandev/sql-qa.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/mohandev/sql-qa.git
许多人提到创建 .gitignore 文件来忽略文件。因此创建了包含以下内容的 .gitignore 文件
*.iso
*.bin
*.ova
然后执行以下命令
git add .
git commit -m 'ignoring certian image files'
git push
但同样的错误再次出现。
如何解决这个问题?
答案1
如果你编写的 gitignore 只包含:
*.iso
*.bin
*.ova
git 只是忽略根目录中的文件 *.iso *.bin 和 *.ova,但不会忽略 images/ 目录中的文件,
你可以试试 :
images/*.iso
images/*.bin
images/.ova
答案2
这是一个可能的解决办法:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch images/*.bin images/*.ova images/*.iso'
如所述这里