9

What is git-daemon? Is it a default git function? I am trying to understand this so that I can host a repository on a server that people can push/pull from.

So far I am able to clone a "--bare" repository onto an Apache server, and then use "update-server-info" to allow the repository to be cloned to other collaborators. However, this does not let collaborators push their commits to the "--bare" repository.

I created the "git-daemon-export-ok" file in my "--bare" repository, and ran the command: "git-daemon --verbose /git" but I get an error: "git-daemon: command not found."

Any help would be appreciated.

junsungwong
  • 303
  • 1
  • 3
  • 10

4 Answers4

5

man git-daemon will tell you quite a bit (and yes, it is a built-in that comes with Git). Git daemon is run via git daemon (notice no hyphen).

However, you should take a look at Gitolite or similar if you intend on hosting Git repositories on a server.

Further, why are you cloning a repository with the intention of having that cloned, and any pushes to it forwarded to the repo it was cloned from? Just clone from the original repository!

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
  • The people I'm working with no longer want to have the repository hosted on Github. They only want it within a network :( Thank you for your advice on Gitolite and git-daemon. There are so many options, from git-daemon to Gitosis to creating a SSH server I feel a little overwhelmed. (Really really wish I could just simply stick to github). I just a solid place to start. Any reason why when I try the command: "git-daemon --base-path=" I get the error "git-daemon : command not found?" – junsungwong Feb 28 '12 at 01:00
  • Git daemon has to be run as `git daemon` (no hyphen), which is a departure from the way most git commands work, but I suppose it's since there are more complicated internal things happening. I've update my answer to reflect that. – Andrew Marshall Feb 28 '12 at 01:07
  • @AndrewMarshall: It's not really a departure. Most or all git commands are invoked as `git foo`, not `git-foo`. On Ubuntu, the `git-*` commands -- including `git-daemon` -- are in `/usr/lib/git-core` (and are invoked by the `git` command), but `/usr/lib/git-core` normally won't be in your `$PATH`. I think older versions of `git` might have behaved differently. (MSYS git on Windows may be different; I don't currently have it installed.) – Keith Thompson Feb 28 '12 at 01:40
  • @KeithThompson I think you're right about older versions, I remember the git-foo variants being exposed in the `$PATH`, which they don't seem to be any more. I suppose this and the fact that you can write any arbitrary git-foo and git foo will [exec it](https://github.com/git/git/blob/master/git.c#L516) led me to say that. But, alas, you are correct, the built-ins now lie outside of the `$PATH`. – Andrew Marshall Feb 28 '12 at 01:49
  • And in MSYS git, the `git-*` tools are in `/libexec/git-core`, which also is not in `$PATH` by default. (I didn't know about the arbitrary `git-foo` thing; that's good to know, thanks.) – Keith Thompson Feb 28 '12 at 01:52
  • 1
    I was reading the documentation supplied in the answer and it says under the description: "This is ideally suited for read-only updates, i.e., pulling from git repositories." I need to be able to push commits to the repositories also. I guess I'll start looking into Gitolite then. – junsungwong Feb 28 '12 at 04:48
0

On your server, in each repository, say, /opt/git/myrepository.git, there is a config file.

Add the following section

[daemon]
    uploadpack = true
    uploadarch = true
    receivepack = true

From the kernel.org page on git-daemon

Allen Supynuk
  • 144
  • 1
  • 4
0

You could have a detailed understanding by reading https://www.kernel.org/pub/software/scm/git/docs/git-daemon.html

As to the problem git daemon not a git command you could read this post about how to installing it.http://androidyue.github.io/blog/2013/09/10/install-git-daemon-on-fedora/

Hope this could help you.

androidyue
  • 952
  • 10
  • 11
0

git daemon could also be used for purpose of migration to an other service provider.

  1. local environment setup
find PATH-TO-LOCAL-REPOSITORIES-ROOT -maxdepth 1 -mindepth 1 -type d -exec touch {}/.git/git-daemon-export-ok  \;
git daemon --verbose PATH-TO-LOCAL-REPOSITORIES-ROOT/*
  1. In case of github you have to put the repository url chosen repository into the form Import your project to GitHub
palik
  • 2,425
  • 23
  • 31