git - 文件在未添加的情况下提交到 git repo
问题描述
我有一个在本地创建并建立远程的 git 存储库。我正在尝试将本地存储库推送到远程以进行初始提交。在我的第一次提交中,我收到了这样一条错误消息:
$ git push -u origin master
Counting objects: 65, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (65/65), 177.27 MiB | 9.18 MiB/s, done.
Total 65 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 47ec2ee4640f0b04863b99c53fa03943
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File test_data/SoMa_DSM.tif is 399.73 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/username/VectorAttributes.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/username/VectorAttributes.git'
我将问题文件的文件夹添加到 .gitignore 中,然后按照此问题中的描述清除了我的缓存:Apply gitignore on an existing repository already tracking large number of files 但是,我又遇到了同样的错误。
据我了解,使用git ls-files
显示已在本地提交的文件应该是 git 尝试推送到远程的唯一文件。我的问题文件没有出现在那里,但错误仍然存在。
为什么 git 仍然试图将该文件添加到远程仓库,即使它不在本地仓库中?
解决方案
一些想法:
当您的文件夹尚未提交时跳转到您的最后一次提交(所有其他文件也可以反转,所以要小心!)
在文件夹被声明为“已删除”的地方进行提交,然后推送。为此,将您的文件夹移动到存储库之外的目录,从 .gitignore 文件中删除条目,添加提交,推送,将文件夹移回添加到 .gitignore,添加提交并推送。不是 100% 确定它是否有效
推荐阅读
- ubuntu - CMUSphinx-go PortAudio 错误:设备不可用
- laravel - Laravel 5 使用 2 个数据库连接加入 2 个表
- python - 在python中随机化快速排序,递归问题
- android - google/android/gms/maps/model/LatLng 的 NoSuchMethodError
- report - 使用 Oracle APEX 5 编辑交互式报表中的行
- apache-spark - 运行结构化流式传输示例“WARN NetworkClient: Bootstrap broker ip-10-28-3-35.ec2.internal:2181 disconnected”时出错
- java - sqlite中的复合索引
- selenium - 使用 Robot Framework 的 Selenium2Library 测试电子应用程序
- c# - stimulsoft 报告是否适用于 exe 文件?
- css - 在运行时为 Angular 应用程序设计样式