文件正在提交到git repo而未添加

时间:2018-10-16 21:40:54

标签: git

我有一个在本地创建并建立远程目录的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仍然试图将文件添加到远程仓库中,即使它不在本地仓库中?

2 个答案:

答案 0 :(得分:0)

一些想法:

  • Applying .gitignore to committed files

  • 在尚未提交文件夹的情况下跳至上一次提交(所有其他文件也可能会反转,所以要小心!)

  • 进行提交,文件夹被声明为“已删除”,然后推送。为此,将文件夹移动到回购目录之外的目录中,从.gitignore文件中删除该条目,添加提交,推送,将文件夹移回将其添加到.gitignore,添加提交和推送。不能100%确定它是否正常工作

答案 1 :(得分:0)

您是否尝试过在推送之前从存储库中删除大文件夹?试试吧:

  

git rm -r-缓存的文件夹名称