Goal: Add a new file to a remote git repository without checking the whole thing out locally.
Why:
I’m building an app that will add files to a user’s git repository. Some of these repositories will be hundreds of megs. Some will be touched very infrequently. I want to avoid taking up terabytes of disk space to keep large repos checked out that won’t be touched often, and I don’t want to incur the inevitable delay of checking out a 200Mb repo (lots of binary files) in order to add a new one new file to it and push that file back to the origin.
I’m assuming the default git client can NOT do this, but am hoping that someone has written something that can commit to a remote repo (don’t care what language) without having the whole thing checked out locally. Does the Cloud9 IDE do something like this?
The app would have full access to the users git repo, either via SSH or whatever mechanism GitHub uses for oAuthed apps to tweak repos.
WARNING: THE FOLLOWING ANSWER NO LONGER WORKS WITH THE MOST RECENT VERSIONS OF GIT
(I’m open to suggestions as to how to make this work with current git versions.)
The answer, it turns out, is amazingly simple, and a testament to just how awesome Git is.
Notes: The remote repo must either be a bare repo or have receive.denyCurrentBranch set to “ignore” or “warn”
This is based on the assumption that the files you are adding are NEW and will not conflict with any other file in the repo.
The existing contents of the remote repository do not matter so long as you can be sure you’re not going to conflict with anything.
P.S. Thank you to everyone who posted the potential workarounds.