I'd like to point out a few things:
- Git can only make commits to a local repo.
- Git compresses files in its repo.
- Git is ill-suited for versioning binaries.
See each section below for full explanation.
Git can only make commits to a local repo
There is no way I know of in Git to make a commit directly to a remote repository, without having to go through a local one first. That's not how Git works. If you want to make commits, I think you can only do so with a local repository.
Git compresses files in its repo
Files under the .git
directory are compressed, so the Git repo at the .git
directory will probably be much smaller than your working copy checkout, especially if it's just full of text and not binary files (more on binary files later). At work, I use a Git repo that's about 300 MB, but the working copy is around 2.5 GB, so the actual repo itself is much smaller in comparison.
Compression settings for Git
You can configure Git to use different compression levels:
core.compression
An integer -1..9
, indicating a default compression level. -1
is the zlib default. 0
means no compression, and 1..9
are various speed/size tradeoffs, 9
being slowest. If set, this provides a default to other compression variables, such as core.loosecompression
and pack.compression
.
core.loosecompression
An integer -1..9
, indicating the compression level for objects that are not in a pack file. -1
is the zlib default. 0
means no compression, and 1..9
are various speed/size tradeoffs, 9
being slowest. If not set, defaults to core.compression
. If that is not set, defaults to 1
(best speed).
pack.compression
An integer -1..9
, indicating the compression level for objects in a pack file. -1
is the zlib default. 0
means no compression, and 1..9
are various speed/size tradeoffs, 9
being slowest. If not set, defaults to core.compression. If that is not set, defaults to -1
, the zlib default, which is "a default compromise between speed and compression (currently equivalent to level 6
)."
Note that changing the compression level will not automatically recompress all existing objects. You can force recompression by passing the -F
option to git-repack(1).
You can read more about Git packfiles from the free online Pro Git book.
Git is ill-suited for versioning binaries
Finally, the original poster makes this comment:
well...the app is dealing with media files... it's 500mb without git
Git is not well-suited to versioning binary files (like media files, like pictures, videos, audio clips, etc), because Git can't keep text diff deltas of changes to them like it can with text files, it actually has to keep each version of a binary in its entirety every time you make changes to it.
So if you have a 1 MB picture file called logo.jpg
, and you make a small change to it, Git would have to store the whole logo.jpg
file all over again, adding another 1 MB to your repository.
Solution 1: Remove binaries with git filter-branch
If your media files don't actually need to be versioned in Git, consider removing them from your repository using git filter-branch
. You can read more about this option at the official Linux Kernel Git documentation for git filter-branch
and at the "The Nuclear Option: filter-branch" of the free online Pro Git book.
Solution 2: use 3rd party services for media files instead
GitHub makes this suggestion for dealing with large media files:
Binary media files don't get along very well with Git. For these files it's usually best to use a service specifically designed for what you're using.
For large media files like video and music you should host the files yourself or using a service like Vimeo or Youtube.
For design files like PSDs and 3D models, a service like Dropbox usually works quite nicely. This is what GitHub's designers use to stay in sync; Only final image assets are committed into our repositories.
More about Git and versioning binary files
You can learn more about Git and versioning binaries in these other Stack Overflow questions:
- Managing large binary files with git.
- git with large files.