Git试图推送未跟踪的文件 [英] Git trying to push file that isn't tracked

查看:115
本文介绍了Git试图推送未跟踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 计数对象:87,done。我试图将我的项目推送到github,并收到以下错误消息: 
使用多达8个线程的增量压缩。
压缩对象:100%(78/78),完成。
写作对象:100%(87/87),50.25 MiB | 1.14 MiB / s,完成。
合计87(delta 32),重用0(delta 0)
remote:警告:文件example-attractor / bin / example-attractor_debug.ilk为51.19 MB;这大于GitHub建议的最大文件大小为50.00 MB
remote:错误:GH001:检测到大文件。你可能想尝试Git Large File Storage - https://git-lfs.github.com。
remote:error:跟踪:f711bd940689c3c64a38c283877b86f8
remote:错误:有关更多信息,请参阅http://git.io/iEPt8g。
remote:error:文件example-attractor / example-attractor.sdf是103.62 MB;这超过了GitHub的文件大小限制100.00 MB
! [remote rejected] master - > master(pre-receive hook refused)
错误:未能推送一些文件

好的,没什么大不了。我为 .gitignore *。sdf *。ilk 删除并添加了所有的文件,并通过 git ls-files 检查了我的跟踪文件:

  .gitignore 
example-attractor / README.md
example-attractor / addons.make
example-attractor / example-attractor.sln
example-attractor / example-attractor.vcxproj
example-attractor / example-attractor.vcxproj.filters
example-attractor / icon.rc
example-attractor / src / main.cpp
example-attractor / src / ofApp.cpp
example-attractor / src / ofApp.h

大!这些文件已从跟踪中删除。我试图再次推送到Github,并得到了同样的错误。我运行了 git status 并且没有任何更改:

 分支master 
您的分支在3次提交之前超过'origin / master'。
(使用git push发布你的本地提交)
没有提交,工作目录干净

我很困惑现在该做什么!为什么git仍然试图推送未被跟踪的文件?

解析方案

其中之前的3次提交。你需要做的是从它们中删除它。通过执行 git rebase -i origin / master 来做到这一点。这将带来一个包含所有这些提交的编辑器。将所有三个提交的pick替换为e,保存并关闭编辑器。 Git将在每次提交后暂停,此时您可以从索引中删除文件,执行 git commit --amend ,然后 git rebase - - 继续。那你应该没问题。

I tried to push my project to github, and received the following error:

Counting objects: 87, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (78/78), done.
Writing objects: 100% (87/87), 50.25 MiB | 1.14 MiB/s, done.
Total 87 (delta 32), reused 0 (delta 0)
remote: warning: File example-attractor/bin/example-attractor_debug.ilk is 51.19 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: f711bd940689c3c64a38c283877b86f8
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File example-attractor/example-attractor.sdf is 103.62 MB; this exceeds GitHub's file size limit of 100.00 MB
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs

Okay, no big deal. I added *.sdf and *.ilk to my .gitignore, removed and added all of my files, and checked my tracked files via git ls-files:

.gitignore
example-attractor/README.md
example-attractor/addons.make
example-attractor/example-attractor.sln
example-attractor/example-attractor.vcxproj
example-attractor/example-attractor.vcxproj.filters
example-attractor/icon.rc
example-attractor/src/main.cpp
example-attractor/src/ofApp.cpp
example-attractor/src/ofApp.h

Great! The files have been removed from tracking. I tried pushing to github again and... got the same error. I ran git status and there's no changes:

On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

I'm perplexed as to what to do now! Why is git still trying to push files that aren't tracked?

解决方案

The most likely explanation is that you committed the file in one of those previous 3 commits. What you will need to do is remove it from them. Do this by doing git rebase -i origin/master. This will bring up an editor with all of those commits. Replace "pick" with "e" for all three commits, save and close the editor. Git will now pause after each commit, at which point you can delete the file from the index, do git commit --amend, then git rebase --continue. Then you should be fine.

这篇关于Git试图推送未跟踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆