我试图将我的项目上传到github,但是它有一个非常大的文件,它高于github文件大小限制。我不想乱用大文件存储,我只能在github上没有这个文件。
我已将文件添加到我的.gitignore
文件中,如下所示:
/Supported Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK
我还从git缓存中删除了这个文件:
git rm -r --cached Supported\ Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK
然后我提交了更改。问题现在,如果我尝试git push -u origin master
时,我从github收到错误:
Counting objects: 6746, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2852/2852), done.
Writing objects: 100% (6746/6746), 139.47 MiB | 724.00 KiB/s, done.
Total 6746 (delta 3804), reused 6597 (delta 3696)
remote: warning: File Supported Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK is 94.00 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: 353c88bf98b546712cb2de8bb086fc17
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File Supported Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK is 110.39 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/myrepo/MyProject.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/myrepo/MyProject.git'
我已经尝试过发布here的解决方案,但由于我有未提交的更改(我还没准备好提交),我收到此错误:
Cannot rewrite branches: You have unstaged changes.
Additionally, your index contains uncommitted changes.
任何人都可以帮我把这个项目带到github。
由于
编辑1 ------
当前git status
:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: MailingList/MailingListViewController.h
new file: MailingList/MailingListViewController.m
new file: MailingListViewController.xib
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Operations/RemoteSettings.h
modified: Operations/RemoteSettings.m
modified: Info.plist
modified: MyProject.xcodeproj/project.pbxproj
modified: MailingList/MailingListViewController.h
modified: MailingList/MailingListViewController.m
modified: MailingListViewController.xib
modified: MediaViewController.m
modified: Supported Files/iRate/iRate.m
modified: ViewController.m
我还没准备好提交这些文件。
答案 0 :(得分:3)
你快到了,solution you linked to就是你需要做的(因为大文件已经在git历史记录中了,所以现在删除没有帮助。)
在你开始之前先收藏所有东西:
`git stash save -u`
(-u
标志使git stash
包含未跟踪的文件,即自上次提交以来已添加到工作树中的文件。通常它们将由git stash
单独保留。 )
然后,根据另一个答案:
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch Supported\ Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK' HEAD
然后,一旦你开心,它就消失了:
git stash pop
恢复工作树的更改。
正如需要注意的那样,请注意filter-branch
会重写历史记录,因此如果其他人看到此存储库,他们将无法合并新的过滤版本。