【发布时间】:2021-10-21 17:43:29
【问题描述】:
我有一个很大的项目要推送到 GitHub,并且将文件推送到 GitHub 的大小有限制,所以我试图只推送一个包含一些文件的文件夹 所以我这样做:
git add android/
git commit -m "my commit"
git push origin dev
但我收到了这样的回复:
remote: error: File build/ios/Release-iphoneos/Flutter.framework/Flutter is 414.78 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/mygit/projectrepo
! [remote rejected] dev -> dev (pre-receive hook declined)
error: failed to push some refs to 'https://...'
虽然我做了git add android/,但似乎我仍然推送所有文件,因为build/ios/Release-iphoneos/Flutter.framework/Flutter 在android 文件夹之外
有没有办法解决这个问题?
【问题讨论】:
-
这看起来像是构建结果文件。您确定要在 git 中对其进行版本控制吗?如果是这样,您应该考虑使用 git lfs 来跟踪大文件
-
理想情况下,您应该忽略生成的所有内容。查看 this 以获取 Flutter 项目的
.gitignore示例。 -
看来您可能没有重置提交。尝试重置为当前提交之前的提交,然后尝试提交并再次推送。如果您已经尝试过,那么一种可能的方法是使用 .gitignore 忽略您不想被 git 跟踪的文件。有关其使用的更多信息是here
-
另外,如果您已经向 github 存储库提交了某些内容(不太可能,根据您的问题),您仍然可以忽略它。见this
-
您不能将 文件 推送到另一个存储库。你只能推送 commits。提交包含文件,并链接回以前的提交。您有一个包含大文件的提交,而 GitHub 拒绝该 提交。你必须停止推送那个特定的commit。请记住,推送新提交也会推送导致该提交的任何先前提交。