3

I am building an app. I have been successfully checking code into GitHub for months. I reached a point where I needed to package my app. So, its getting packaged into an ASAR file. Unfortunately, I did not add the file to my .gitignore file. Now, when I attempt to check in code, I'm getting the following error:

GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        
Trace: [ID]        
See http://git.io/iEPt8g for more information.        
File App/MyApp.asar is 153.32 MB; this exceeds GitHub's file size limit of 100.00 MB

I understand the issue. However, I do NOT want to actually checkin my ASAR file. So, I added it to my .gitignore file. I then attempted to Sync my code changes to GitHub, and I'm still getting the error listed above. From what I can tell, my code changes have been committed to my local branch. However, a log jam is happening because the file listed above was already attempted to be checked in.

I'm not sure how to unblock the jam though. I need the code changes that were in that commit. But, I don't need the ASAR file. I feel stuck, yet, I'm not sure how to get unstuck. Any help is appreciated.

xam developer
  • 1,923
  • 5
  • 27
  • 39

5 Answers5

2

Well, since You have already commited this change (since You want to push your local commits to Github), You will need to revert this change before pushing to remote server, check this answer on how to do that (git reset --soft HEAD~ followed by changes (ie removing this large file), and new commit)

Community
  • 1
  • 1
JustMe
  • 710
  • 4
  • 16
1

You need to remove the file from your history before pushing. Let's say the commit where you added the file was abc123. Execute git rebase -i abc123^. This will open up an editor listing that commit, and all commits since. For the line that contains the commit in question, replace "pick" with "e", then close the editor. Git will replay the commit, then stop. Type git rm --cached <filename>, then git commit --amend. Then you should be able to push.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54
0

As you can see in your error messages git has a size limit for file size.

You will have to remove the large file from your repository.
You can do it in several ways:


There are many different ways to remove the history of a file completely from git, here are few options:

  • git rebase
  • Interactive rebase.
  • Filtering branches.

git rebase

Assuming you have several commits and not only one you will have to perform a rebase.

# Checkout the commit where you commited the big file
git checkout -b <branch name> <SHA-1>

# Amend the commit
git rm <file>
git commit --amend --no-edit

# Rebase your previous branch onto this new commit, starting from the old-commit
git rebase --preserve-merges --onto <branch name> <old-commit> <original branch name>

Interactive Rebase (git rebase -i/-p)

enter image description here

Interactive rebase lets you modify the history in a manual way. Keep in ind that since its a manual work it will be hard to do it on too many commits.

// X is the number of commits you wish to modify
git rebase -i HEAD~X

Once you have the editor opened

  • Choose s for squash = it will combine all the commits into a single commit.

  • Choose e for editing the desired commit, git will stop rebasing at this commit then remove your file and commit it again (git ammend for any given commit and only the last one).

Example:

# rebase has stopped at the given commit. edit it and remove our file
# same as you will do if it was the latest commit without using rebase
git rm <file>
git commit --amend --no-edit

# once the file removed - continue to the other commits if needed.
git rebase --continue

Filtering branches

'git filter-branch'

git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <file>'

That will execute the given command on all of the commit range you choose (X in this code snippet to remove unwanted files from your history:

git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <file>' HEAD~X..HEAD

bfg-repo-cleaner

But bfg-repo-cleaner is a much faster solution than git filter-branch

enter image description here

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
-2

Try removing the file from the git index with this:

git rm FILEYOUWANTTOREMOVE

Then commit the new changes. More information here: git-rm

HeroCC
  • 988
  • 15
  • 33
-2

When you change your .gitignore file, don't forget to clear the cache like this :

git rm --cached your_file

Also, if you still have problem with your big file, I suggest you take a look at this : Git non-cached file being uploaded to Github

Hope this helps !

Community
  • 1
  • 1
haltode
  • 618
  • 6
  • 15