正在上传到Github的Git非缓存文件 [英] Git non-cached file being uploaded to Github

查看:201
本文介绍了正在上传到Github的Git非缓存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将我的项目上传到github,但是它有1个超过github文件大小限制的非常大的文件。我不想惹恼大型文件存储,我只能在github上没有这个文件。



我已经将文件添加到我的 .gitignore 这样的文件:

  /支持的文件/ AviarySDK / AviarySDK.framework /版本/ A / AviarySDK 

我也从git缓存中删除了这样的文件:

  git rm -r --cached Supported \ Files / AviarySDK / AviarySDK.framework / Versions / A / AviarySDK 

然后我提交了更改。现在的问题,如果当我试图 git push -u origin master 我从github得到一个错误:

 计数对象:6746,完成。 
使用多达8个线程的增量压缩。
压缩对象:100%(2852/2852),完成。
写作对象:100%(6746/6746),139.47 MiB | 724.00 KiB / s,完成。
合计6746(delta 3804),重复使用6597(delta 3696)
remote:警告:文件支持的文件/ AviarySDK / AviarySDK.framework / Versions / A / AviarySDK是94.00 MB;这大于GitHub建议的最大文件大小为50.00 MB
remote:错误:GH001:检测到大文件。你可能想尝试Git Large File Storage - https://git-lfs.github.com。
remote:error:跟踪:353c88bf98b546712cb2de8bb086fc17
remote:错误:有关更多信息,请参阅http://git.io/iEPt8g。
remote:错误:文件支持的文件/ AviarySDK / AviarySDK.framework / Versions / A / AviarySDK是110.39 MB;这超过了GitHub的文件大小限制为100.00 MB
到https://github.com/myrepo/MyProject.git
! [remote rejected] master - > master(pre-receive hook refused)
错误:未能将一些文件推送到'https://github.com/myrepo/MyProject.git'

我试过解决方案发布这里,但因为我有未提交的变化(我没有准备好提交)我得到这个错误:

 无法重写分支:您有未分离的更改。 
此外,您的索引包含未提交的更改。

任何人都可以帮我把这个项目放到github上。



谢谢

编辑1 ------



当前 git status

 分支大师
要提交的更改:
(使用git reset HEAD< file> ...来取消)

新文件:MailingList / MailingListViewController.h
新文件:MailingList / MailingListViewController.m
new file:MailingListViewController.xib

没有为commit提交更改:
(使用git add< file> ...更新将提交的内容)
(使用 git checkout - < file> ...放弃工作目录中的更改)

修改:Operations / RemoteSettings.h
修改:Operations / RemoteSettings.m
修改:Info.plist
修改:MyProject.xcodeproj / project.pbxproj
修改:MailingList / MailingListViewController.h
修改:MailingList / MailingL istViewController.m
修改:MailingListViewController.xib
修改:MediaViewController.m
修改:支持的文件/ iRate / iRate.m
修改:ViewController.m

我还没有准备好要提交这些文件。

解决方案

您几乎就在那里,您链接的解决方案就是您需要的(因为大文件已经在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 会重写历史记录,所以如果其他人看到了这个存储库,他们将无法合并新过滤的版本。


I m trying to upload my project to github, however it has 1 very large file which is above the github file size limit. I don't want to mess around with the large file storage, I can live with simply not having this file on github.

I have added the file to my .gitignore file like this:

/Supported Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK

I have also removed the file from the git cache like this:

git rm -r --cached Supported\ Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK

I then committed the changes. The problem now, if when I try to git push -u origin master I get an error back from 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'

I've tried the solution posted here but as I have uncommitted changes (Which i'm not ready to commit) I get this error:

Cannot rewrite branches: You have unstaged changes.
Additionally, your index contains uncommitted changes.

Can anyone help me getting this project onto github.

Thanks

Edit 1------

current 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

I'm not ready for these file's to be committed yet.

解决方案

You're nearly there, the solution you linked to is what you need to do (because the large file is already in the git history, so deleting now doesn't help).

Just stash everything before you start:

`git stash save -u`

(The -u flag makes git stash include untracked files, i.e. files that you've added to the working tree since the last commit. Normally they would be left alone by git stash.)

Then, as per the other answer:

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch Supported\ Files/AviarySDK/AviarySDK.framework/Versions/A/AviarySDK' HEAD

Then once you're happy it's gone:

git stash pop

To restore your working tree changes.

Just as a note of caution, be aware that filter-branch does rewrite history, so if anyone else has seen this repository they will have trouble merging with the newly filtered version of it.

这篇关于正在上传到Github的Git非缓存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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