Git clone works fine but git push doesn’t

git

I have created a test git repo on Git server:

/var/cache/git/username/myGitRepo.git

Which is a 'bare' git repo. The ownership of the files belong to this 'username' user. I can clone the above Git repo, on another Windows machine.

git clone git://myhost/var/cache/git/username/myGitRepo.git

The repo clones correctly. Then I can do local commits and try to push the changes back to my Git server:

git push origin master

But that gives a permission error on the server:

fatal: remote error: access denied or repository not exported: /git/username/myGitRepo.git

I added the magic file 'git-daemon-export-ok' file in the repo dir. But I keep getting the above error.

I even set the chmod to 777 of the /var/cache/git/username/myGitRepo.git

Getting same error.

Git remote -v throwing following output.

$ git remote -v
origin  git://myhost/git/username/myGitRepo.git (fetch)
origin  git://myhost/git/username/myGitRepo.git (push)

Anyone could help me to get this error resolved?

Best Answer

Out of the box, the standard git-daemon does not allow you to push into repositories. The man page says:

This is ideally suited for read-only updates, i.e., pulling from git repositories.

If you really want to enable anonymous push (and really, you don't; just use ssh), you need to enable the receive-pack service, which is disabled by default (because it's a bad idea). Again, from the man page (the SERVICES section):

receive-pack

This serves git send-pack clients, allowing anonymous push. It is disabled by default, as there is no authentication in protocol (in other words, anybody can push anything into the repository, including removal of refs).

The bold is mine. You can enable this service globally by passing the --enable=receive-pack command line option, or per-repository by setting daemon.receivepack to true in your repository's git configuration.

Related Topic