gitosis and git clone problem
Asked Answered
D

5

2

I have installed gitosis, but i have strange thing when i'm working with repos. In config i have

[gitosis]

[group gitosis-admin]
writable = gitosis-admin
members = me@server me@laptop

[group prj1]
writable = prj1
members = me@laptop

and in /home/git/repositories i have created directory prj1.git with empty git repo.

i can work with gitosis-admin from server and laptop without problems, but when i'm trying to git clone prj1 on my laptop i see

$ git clone git@server:prj1.git
Initialized empty Git repository in /Users/alec/temp/prj1/.git/
fatal: no matching remote head

ok, lets push prj1 from laptop to server:

$ git push origin master:refs/heads/master
ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly

Whats wrong?

Darg answered 19/8, 2009 at 6:54 Comment(0)
S
5

Would the following, done on your laptop, solve this issue?
Instead of a git clone:

  mkdir prj1
  cd prj1
  git init
  touch README
  git add .
  git commit -m "Added blank readme"
  git remote add origin git@server:prj1.git
  git push origin master

ebneter adds in the comment:

You might mention that the reason this works is that you can't clone an empty repo.
(As my users regularly discover...

And that reminds the OP question:

... and in /home/git/repositories I have created directory prj1.git with empty git repo

which is not ideal right there.
This SO question mentions the issue of cloning an empty repo:

In other words, don't attempt to clone the empty repo, but rather after creating it, push to it a simple repo containing one innocuous file. Then it is no longer empty and can be cloned.


Since then, Chris Johnsen comments:

Any Git later than 1.6.2

(so actually since March 2009)

can “clone” empty repositories.
(scare quotes because it really just amounts normal initialization plus setting up a remote, and creating a tracking configuration for the presumed, eventual master branch).

Salaried answered 19/8, 2009 at 7:4 Comment(1)
Any Git later than 1.6.2 can “clone” empty repositories (scare quotes because it really just amounts normal initialization plus setting up a remote, and creating a tracking configuration for the presumed, eventual master branch).Evania
F
5

I had the same problem which persisted even after following the steps in Answer 1.

sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

solved it for me. Apparently older versions of setuptools can make the post-update hook non-executable. Refer this page.

Flatfooted answered 29/5, 2010 at 9:30 Comment(0)
H
1

I ran into the same message, after I want to push to a new repository:

git push -u origin master
ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly

The reason was that I had 2 same ssh pub-keys (same key, different name) in gitosis-admin/keydir.

After deleting one of it, I can push to new repositories

Hypethral answered 10/11, 2011 at 20:54 Comment(1)
Make sure o remove one of them from ~gitosis/.ssh/authorized_keysEmmi
M
0

Had the same problem, the reason was that I edited gitosis.conf on my local and did not commit it to server.

Mock answered 24/12, 2011 at 10:33 Comment(0)
F
0

In my case, ssh client picked the wrong private key from ~/.ssh.

[gitosis] loglevel = DEBUG helped seeing that the wrong user was being logged in.

Falsework answered 26/8, 2013 at 19:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.