tags:

views:

2245

answers:

1

(Solved already, I'm writing this for the next guy)

I was running git daemon on one computer and tried synchronizing with another.

On computer A, I ran:

git daemon --reuseaddr --base-path=. --export-all --verbose

On computer B, I ran:

git clone git://computerA/.git source # worked
cd source
git pull # worked
git push # failed with "fatal: The remote end hung up unexpectedly"

On computer A, the daemon output is:

[5596] Connection from 127.0.0.1:2476
[5596] Extended attributes (16 bytes) exist <host=localhost>
[5596] Request receive-pack for '/.git'
[5596] 'receive-pack': service not enabled for './.git'
[5444] [5596] Disconnected (with error)

I'm going to post the soultion I found. If you have a more complete answer, please go ahead and add it.

+7  A: 

Simply run

git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack

(on computer A, instead of the original git daemon command), and the push works.

Note that you have to then run

git reset --hard

on computer A to make it "see" the changes from computer B.

Post Script

The problem with doing a hard reset is that it overwrites whatever local changes you had on computer A.

Eventually I realized it would make much more sense to have a separate repository (a bare clone) that doesn't have any files in it, then have computer B push to it and computer A pull from it. This way it can work both ways and merge all the changes in a smooth fashion. You can even have two bare clones, one on each computer, and push-pull between them.

itsadok
Is there anything I can do to not have to run `git reset --hard` after a push to see the changes?
Rohit
Depends on why you don't want to run it. If you just want to minimize typing, you can set up a hook (check out http://utsl.gen.nz/git/post-update for an example). Otherwise, see my PS.
itsadok
I am using the other (non bare) repository as a backup on a mounted NAS. I could set up a simple backup script but that had some other problems. I'll check out the the hook thing and your script. Thanks a lot!
Rohit
Thank you so much... it worked for me!
Cristian