'receive-pack': service not enabled for './.git'

Git

Git Problem Overview


(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.

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

I encountered this error, but the solution seems different for those using git-http-backend. (git push/pull/clone over http instead of ssh or git)

This must be done on the remote server, and is best done on creation. (last line can be run independently if repo already exists / is in use)

$ mkdir eddies  # MAKE folder for repo
$ chown -R eddie:websrv eddies/  #ensure apache (webserver) can access it
$ cd eddies/
$ git --bare init --shared
Initialized empty shared Git repository in /var/git/eddies/
$ ls
branches  config  description  HEAD  hooks  info  objects  refs
$ git config --file config http.receivepack true

Solution 3 - Git

I have some issue with the git reset --hard so here is my alternative solution.

On the local cloned repo make a branch

git checkout -b my_new_branch

on the remote origin repo enable the receive-pack service

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

push the new branch to remote origin

git push origin my_new_branch

merge the new branch on origin with

git merge my_new_branch

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionitsadokView Question on Stackoverflow
Solution 1 - GititsadokView Answer on Stackoverflow
Solution 2 - GitEddieView Answer on Stackoverflow
Solution 3 - GitBenjamin Udink ten CateView Answer on Stackoverflow