0

I've been wracking my brain over this and came to a possible conclusion with no solution. First, my dilemma.

I have a project where I can create a repo programmatically. I can edit the description of the repo, set the default branch, &c. This is fine.

I am also using git daemon to serve the folder where all the generated repos are kept. Here's where the issue steps in.

I am able to clone the repo but the cloned repo's .git contents don't match the original repo.

The only thing I can think of is that when I am creating these repos I am using my system's git process but when cloning I am using the git daemon's process...I'm not even sure that makes sense and my hours of searching have turned up nothing.

For reference, here's the command I run to activate git daemon:

git daemon --reuseaddr --port=9999 --base-path=/Users/me/repos/ --export-all --verbose --enable=receive-pack --informative-errors --detach

Here's an example of a clone command:

git clone git://localhost:9999/me/test18.git

And here are the commands I run to create the repos:

git init
git remote add origin git://localhost:9999/me/repo.git
git symbolic-ref HEAD refs/heads/magic
# more stuff

These things work, I just need git daemon to serve my repos the way they are.


Here's an example of the contents of .git/config in the repo I create:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git://localhost:9999/me/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "coolerbranch"]
    remote = origin
    merge = refs/heads/coolerbranch

Here is that same repo cloned:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git://localhost:9999/me/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

As you can see, the [branch ...] section doesn't match.


Conversely, if there's another git daemon out there that I haven't found I'd love to hear about it. Github had been working on their own several years ago but abandoned it.

Also, I originally posted this question on SO but after further searching on other SE sites, I realized SF has more git-daemon-esque questions.


@Zoredache:

Cloning a repo doesn't copy the configuration. Configuration is mostly local to the computer, user, or directory.

Without this knowledge, I was assuming there'd be a way to get git to sync the initial config upon cloning. Git's defaults are not overrideable by a server, only by the user.

Maybe git will allow this option someday, most likely not. Ah well.

  • I guess another way to ask is, how do I run commands against git-daemon over the built-in/system git? – NetOperator Wibby Jan 29 '20 at 20:45
  • I think git-daemon usage is pretty uncommon, and most people just use SSH for read-write, and just the http backend for read-only. – Zoredache Jan 29 '20 at 21:04
  • I feared this was the case but had hoped I simply overlooked an article written on a random blog 12 years ago with a useful nugget of info that still worked. Alas, not this time. – NetOperator Wibby Jan 29 '20 at 21:14
  • BTW, you may need to be more specific on what you mean by `the cloned repo's .git contents don't match the original repo`. What exactly is different? Is it a completely different repo with no similar commits, or what? I am not a git daemon expert, but I am not sure you have given enough information yet, that I could attempt to replicate or even recognize the problem you are trying to get help with. – Zoredache Jan 29 '20 at 21:17
  • You're right, I just added more context. – NetOperator Wibby Jan 29 '20 at 21:24
  • `As you can see, the [branch ...] section doesn't match.` cloning a repo doesn't copy the configuration. Configuration is mostly local to the computer, user, or directory. – Zoredache Jan 29 '20 at 22:45
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/103863/discussion-between-netoperator-wibby-and-zoredache). – NetOperator Wibby Jan 29 '20 at 23:04

1 Answers1

0

I don't think the cloned .git should match the servers .git contents. For setting up a server, I would recommend that you follow the directions in the book https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server.

Kevin Buchs
  • 353
  • 1
  • 3
  • 20
  • I've been over that page several times. Thanks to my discussion with @Zoredache, I discovered that git doesn't sync configs. Seems like an oversight but I guess there's nothing I can do about that. – NetOperator Wibby Jan 29 '20 at 23:15