tags:

views:

45

answers:

2

Does Git support any commands that would allow me to commit directly from a local/working tree into a remote repository? The normal workflow requires a "git add", at least, to populate the object database with copies of the file contents, etc.

I understand that this is NOT the normal, expected Git workflow. But I noticed that Git already supports downloading directly from the repository, with no local repo ("git archive"), so it seems reasonable that there might be a similar uploading operation.

Alternatively, if there isn't such a command in the core Git itself, does any 3rd-party software support direct remote writes?

+1  A: 

As far as I know, no (not directly, see my completed answer at the end):

Here is the official Git data workflow, between a local and a remote repo:

alt text

As you can see, git add is related with the index, and will not yet influence your local repo.
The all set of commands are here to help enforce some publication policies:

alt text


The only way to directly influence a remote repo with local changes (as changes in your working directory are entirely unknown to Git) would be to:

git diff -p origin > diff_not_in_origin.patch

send the patch and see that the "origin" server has some kind of trigger in place which will git am said patch automatically.

VonC
Thanks VonC, v. thorough explanation. If I understand 'git am' correctly, it calls 'git apply' on the back end. Based on the man pages, I believe 'git apply' can't work on a bare repo. So, it sounds like the best I can do, here, is move the index/object DB operations (and disk usage) to the remote host?
Ryan B. Lynch
@Ryan: yes, or you can move only *one* file with git bundle (http://stackoverflow.com/questions/2545765/how-can-i-email-someone-a-git-repository/2545784#2545784) and make your bare repo (http://stackoverflow.com/questions/1830701/how-do-i-check-if-a-repository-is-bare/1830712#1830712) there (with various possibility from there: http://stackoverflow.com/questions/2400043/automatically-pulling-on-remote-server-with-git-push/2400914#2400914).
VonC
A: 

No.

What you're asking is backwards and doesn't make any sense. Maybe you want to use svn instead.

The only way to send stuff to a remote repository is if it's already in your local repository. You can't skip that step.

Hell, even if you manage to not create any object locally, you still have to have the file content locally, and send it over the network. And if you have more than one file edited, it's probably more efficient (at least space-wise) to store them in the local object database first; at least they might get compressed.

Either way, you could probably write a utility that does this, and ask for it to be integrated into git .. I really doubt that anyone would find it useful though.

Keep in mind that git has no concept of a central repository. The only thing you can do to a remote repo is push commits, and commits can only be pushed if they can be merged with the remote's branch tip using fast-forward, and the remote has to a bare repo.

hasen j
Some of your language is pretty confrontational. Phrases like "What you're asking is backwards and doesn't make any sense" and "I really doubt that anyone would find it useful though." As I mentioned in my question, I already understand that I'm asking about a non-standard workflow, and that what I'm proposing isn't how Git was intended to operate. So does your answer really add anything to the discussion?
Ryan B. Lynch