Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't push to Git, due to binary files

So I've been having issues pushing to my master branch that ive been working due to some binary video files. The files were too large when I tried to push them the first time. So I removed them out of the directory of the project I was working on. But now when I try to push ever since that first initial push and it returns me this error message.

Compressing objects: 100% (38/38), done.
Writing objects: 100% (39/39), 326.34 MiB | 639.00 KiB/s, done.
Total 39 (delta 16), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: Trace: b7371dc6457272213ca1f568d9484c49
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File themes/SomeFile/uploads/me_582610_mountain-river.mov is 315.08 MB; this exceeds GitHub's file size limit of 100 MB
To [email protected]:UserName/Project.git

The file it says is too large and seems to still be there somehow isn't actually there at all in my directory or even on my computer. I deleted it completely. What is the problem here? This is my first time ever having issues with this. I went to the referenced Git site for support, https://help.github.com/articles/working-with-large-files/ , and ran the git rm --cached me_582610_mountain-river.mov and it returns me the message fatal: pathspec 'me_582610_mountain-river.mov' did not match any files

Please any help would be greatly appreciated!

like image 923
bigREDcode Avatar asked Oct 22 '14 20:10

bigREDcode


People also ask

Does git work with binary files?

Git LFS is a Git extension used to manage large files and binary files in a separate Git repository. Most projects today have both code and binary assets. And storing large binary files in Git repositories can be a bottleneck for Git users.

Can I upload binary files to GitHub?

The only part of the GitHub web interface which allows you to push a binary (or any other file you want) is when creating a release.

Why is push not working in git?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

Why am I not able to push to GitHub?

Simply put, git cannot make the change on the remote without losing commits, so it refuses the push. Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.


1 Answers

Remember, by default, everything you commit to git remains in your repo - even if you "delete" it in a later commit.

One of GIT's weaknesses (along with other DVCS') is that it doesn't handle large binary files very well. Many teams/people wanting to version lots of large binary files prefer centralized VCS' like Perforce, Subversion, etc. where one has greater control over what part of a repo one downloads and how many versions of prior commits one persists in a repo.

To your problem: You have a repo into which you've previously committed a large binary file. Even though you subsequently "removed" it from your repo, the file remains. To fully delete it from your repo, you'll have to do some surgery, physically destroying the original commit in which the file was added, and then rewriting every subsequent commit in your repo!

As per the GIT Documentation on removing objects (emphasis mine):

There are a lot of great things about Git, but one feature that can cause issues is the fact that a git clone downloads the entire history of the project, including every version of every file. This is fine if the whole thing is source code, because Git is highly optimized to compress that data efficiently. However, if someone at any point in the history of your project added a single huge file, every clone for all time will be forced to download that large file, even if it was removed from the project in the very next commit.

The solution to your problem is not a simple process, is destructive (in that it basically rewrites every commit after the commit in which you included the offending file(s)) and is pretty well documented in the above link which I encourage you to read several times and practice on a local copy of your tree before updating your official tree.

Proceed with care!

If you do this immediately after an import, before anyone has started to base work on the commit, you’re fine — otherwise, you have to notify all contributors that they must rebase their work onto your new commits.

Frankly, when I did this a year-or-so ago with a repo of my own (i.e. not shared with anyone else), I chose to copy my current codebase to a new folder and create a new GIT repo from it rather than try to rewrite all my history, packfiles, etc. Losing the history wasn't a major issue for me at the time.

Good luck!

like image 142
Rich Turner Avatar answered Oct 29 '22 07:10

Rich Turner