2016-02-05 24 views
2

我想我的項目推到github上,並收到以下錯誤文件:Git的努力推動未進行跟蹤

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 

好了,沒什麼大不了的。我加了*.sdf*.ilk.gitignore,刪除,並添加我的所有文件,並通過檢查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並沒有改變:

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 

我困惑,現在怎麼辦!爲什麼git仍然試圖推送未被追蹤的文件?

+0

可能的重複[如何在我的分支由5個提交超前主提交時刪除提交中的一個太大的文件](http://stackoverflow.com/questions/20002557/how-to-remove-a-too -large-file-in-a-commit-when-my-branch-is-ahead-of-master-by) – Powerlord

+0

不幸的是,沒有解決方案解決了我的問題:( –

回答

3

最可能的解釋是您在前3次提交之一中提交了該文件。你需要做的是從它們中刪除它。通過做git rebase -i origin/master來做到這一點。這將帶來一個包含所有這些提交的編輯器。將所有三個提交的「pick」替換爲「e」,保存並關閉編輯器。每次提交後,Git都會暫停,此時您可以從索引中刪除文件,請執行git commit --amend,然後git rebase --continue。那你應該沒問題。

1

Great! The files have been removed from tracking.

從未來的追蹤,是的。但是您仍然在您當地的分支機構歷史記錄master中有提交。

Why is git still trying to push files that aren't tracked?

當你推送一個分支時,它的所有祖先提交還沒有在遠程被推送到那裏。

I'm perplexed as to what to do now!

從分支的歷史記錄中刪除不需要的文件,無論是like David suggestsgit rebase -i origin/master而在master分支,或with git filter-branch。無論哪種情況,請在更改任何歷史記錄之前備份您的存儲庫。