0

(Just in case it makes a difference, this is on Github Enterprise)

I can't push changes out to a repo because I unwittingly committed two overly-large files to my local repo. These two files exceed the size allowed by github. I'm now locally several commits behind the origin. I don't care about the large files and have since removed them, but git push origin still fails every time.

When I check the last commit in github, the repo is 10 days behind, meaning that not only do the large files fail, but the entire push fails. I apparently cannot push my repo anymore. Every time I try, I get this error:

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: File lib/abc.csv is 482.56 MB; this exceeds GitHub Enterprise's file size limit of 150.00 MB
remote: error: File lib/xyz.csv is 604.82 MB; this exceeds GitHub Enterprise's file size limit of 150.00 MB
To https://github.foobar.com/userx/myrepo
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.foobar.com/userx/myrepo'
  • I want to push my current local repo out to the github repo.
  • I don't care at all about the overly-large files. I do not need to push them out to github.
  • My local repo is many commits ahead of the github repo. The commit with the overly-large files is not the most recent.

Is there a way to fix this without rolling my local repo all the way back to the commit where the large files were added?

Matt Flowers
  • 131
  • 1
  • 6

2 Answers2

1

No. You must rebuild your history removing all commits which contain the big files.

To do so:

git rebase -i origin/master master

If your bad commits are only an add of big files, just delete them deleting the concerned lines in the rebase todo file.

If your big files belong to a more complex commit, use "edit" option in the rebase todo file on each concerned line. When the rebase operation stops just after the commit to amend:

git rm bigFile1 bigFile2
git commit --amend
git rebase --continue

Terminate the rebase, resolving all conflicts if necessary.

Finally, push again.

jbaptperez
  • 656
  • 6
  • 20
1

I found that you can

git reset --soft <commit>

where "commit" was the commit where you committed the large file. (you can list your branches commits using git log) Then

git rm --cached "largeFileName"

then commit and push.

What I understand of it is that the soft reset changes you back to that previous commit without changing your local files. git rm --cached undoes you previous git add "largeFileName" so it isn't staged for commit

git status is a helpful command to see what git has prepared to commit (when my large file was finally off the stage it listed it as deleted in green)