Question

I have two issues. I have Ubuntu 10.10 and I have installed git server with gitolite tool. Everything worked quite good. The gl-setup command of gitolite created 2 repositories: gitolite-admin and testing.

1) QUESTION 1

My default gitolite admin user is called "git" and already created.

First, I had to clone the gitolite-admin repo, make some changes to let's say conf/gitolite.conf to add some new repo and a new user (I added the root user and I created and private/public key before and also added the public key to keydir folder), then I had to add/commit and push changes back.3

Info: I have my ~git/.ssh/authorized_keys file fine, starting with command= and having only one value - the public key of the git user I created first.

DIDN'T WORK:

git@vs1:~/$ git clone git@<<SERVER_IP>>:gitolite-admin.git
Initialized empty Git repository in /home/git/ga/gitolite-admin/.git/
git@<<SERVER_IP>>'s password:
fatal: 'gitolite-admin.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

WORKED:

touch ~/.ssh/config

with content:

host gitolite
     user git
     hostname <<SERVER_IP>>
     identityfile ~/.ssh/git.pub

git@vs1:~/$ git clone gitolite:gitolite-admin
Initialized empty Git repository in /home/git/ga/gitolite-admin/.git/
Enter passphrase for key '/home/git/.ssh/git.pub':
Enter passphrase for key '/home/git/.ssh/git.pub':
Enter passphrase for key '/home/git/.ssh/git.pub':
git@89.35.160.243's password:
remote: Counting objects: 23, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 23 (delta 4), reused 0 (delta 0)
Receiving objects: 100% (23/23), done.
Resolving deltas: 100% (4/4), done.

Why I didn't work at all the first variant? All the tutorials say that it should work without any problems. I had to use the second variant with creating that host configuration in ~/.ssh/config file. This is a bit frustrating. The repo path is /home/git/repositories and the ssh is default port 22.

2) QUESTION 2

Using user root on the same server, I created an empty folder in let's say /var/www/example.com/www. I ran git init, then added a file (.gitignore), ran git add -A and git commit -m "...".

Then I created the remote path for origin:

git remote add origin git@<<SERVER_IP>>:myrepo.git

I ran git push origin master and this is what I got:

fatal: 'myrepo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I tried various things to change, like putting the whole path to the repository (even I didn't see that nowhere, so it isn't correct) and I got:

Counting objects: 3, done.
Writing objects: 100% (3/3), 243 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: ENV GL_RC not set
remote: BEGIN failed--compilation aborted at hooks/update line 20.
remote: error: hook declined to update refs/heads/master
To git@<<SERVER_IP>>:/home/git/repositories/myrepo.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'git@<<SERVER_IP>>:/home/git/repositories/myrepo.git'

What I doing wrong? This is getting frustrating since for such basic task I experience this unusual difficulties. I have great experience with SVN, these are the first plays with GIT.

Thank you in advance for your help!

Was it helpful?

Solution

Note for 1/: That could have worked if the identityfile was a default name (id_rsa.pub and id_rsa). Since it wasn't the case, a config file was mandatory.

Note for 2/ you have created a git repo, but did you let gitolite know about it?
You should declare the new repo in the config file of the gitolite-admin repo.

If you are pushing through ssh as root, that means that use has its own ~/.ssh/id_rsa(.pub) keys, and those keys were registered for Gitolite.

Note for repo paths: never use the full local path of a repo for the push/pull address: that would circumvent Gitolite completely.


A gazillon comments laters, it appears that:

  • all remote addresses should start with git@somehostname:arepo.git: you want your user to execute git commands on somehostname as 'git' (the account in charge of git and gitolite).
    That means the public key of 'myuser' needs to be registered on the somehostname:~git/.ssh/authorized_keys

  • any time an ssh connection doesn't go your way, you can start by looking those ssh debugging tips.
    For instance: ssh -vvv git:somehostname can go a long way to illustrate what is going on

  • if you want to avoid a config file, then you need to use the standard naming convention for those public/private keys (~myuser/.ssh/id_rsa, and ~myuser/.ssh/id_rsa.pub)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top