Darren
Darren

Reputation: 10398

Git non-cached file being uploaded to Github

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.

Upvotes: 3

Views: 367

Answers (1)

N3dst4
N3dst4

Reputation: 6435

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.

Upvotes: 3

Related Questions