3

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.

Community
  • 1
  • 1
Darren
  • 10,182
  • 20
  • 95
  • 162

1 Answers1

3

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.

Community
  • 1
  • 1
N3dst4
  • 6,360
  • 2
  • 20
  • 34
  • Thanks. I can feel i'm getting closer. When I run the `filter-branch` command it rewrites but ends with `WARNING: Ref 'refs/heads/master' is unchanged` and the `git push` still complains of the large file. – Darren Jan 15 '16 at 11:27
  • Hey I got it to work. Firstly I didn't escape the white space in the path in my `.gitignore`. After I did that and started the process again, the `filter-branch` command worked and everything got uploaded. Also, I can't thank you enough for the `stash` command. This will come in very handy in future and makes git so much better (I'm a git novice). – Darren Jan 15 '16 at 12:15
  • Stash is a godsend. Hey @N3dst4, why `git stash save -u` vs `git stash`? It looks like `save -u`, which I've never used, gives you a new reference point by which you can `git reset --hard` back to. If the intention is to `pop` later, why is this beneficial? [Reference site on `git stash`](https://git-scm.com/docs/git-stash). – mbb Jan 15 '16 at 13:20
  • -u is shorthand for --include-untracked – N3dst4 Jan 15 '16 at 13:38
  • Edited to explain `git shtash -u` – N3dst4 Jan 15 '16 at 14:16