10

I am trying to push content from a workstation to a server. But it gives me an error. Please look at the following for command and error:

Administrator@ganesh ~/testing  
$ git push origin master  
Counting objects: 3, done.  
Writing objects: 100% (3/3), 241 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@ganesh:repositories/testing  
 ! [remote rejected] master -> master (hook declined)  
error: failed to push some refs to 'git@ganesh:repositories/testing'  

It seems that I need to set the environment variable GL_RC. Is this so?

Can anyone here tell me what the problem might be and how I can solve it? I am using gitolite on Windows Server 2003.

Jason Plank
  • 2,336
  • 5
  • 31
  • 40
amar4kintu
  • 831
  • 11
  • 21
  • 32
  • 1
    It's prefixed with 'remote:', which means the gitolite update hook prints that error. It seems gitolite is not correctly configured in the repository. – Jan Hudec Mar 08 '11 at 13:42
  • How to find the problem? I am not getting exactly. should I reinstall gitolite? – amar4kintu Mar 08 '11 at 13:56

4 Answers4

9

As illustrated in the doc ssh troubleshooting, this is probably caused by an incorrect path during cloning.

The documentation (some parts below were only valid for Gitolite V2) mentions:

The second error

(ie. "you are able to clone repositories but are unable to push changes back (the error complains about the GL_RC environment variable not being set, and the hooks/update failing in some way)

happens if you use git@server:repositories/reponame.git (assuming default $REPO_BASE setting -- in Gitolite V3, it always is ~/repositories) -- that is, you used the full unix path.
Since the "prefixing" mentioned above is not required, the shell finds the repo and clones ok.
But when you push, gitolite's update hook kicks in, and fails to run because some of the environment variables it is expecting are not present.

The message that appears on a successful run of the "easy-install" program clearly includes the following warning:

*Your* URL for cloning any repo on this server will be
        gitolite:reponame.git

    *Other* users you set up will have to use
        <user>@<server>:reponame.git
    However, if your server uses a non-standard ssh port, they should use
        ssh://<user>@<server>:<port>/reponame.git

So in your case, you must have cloned your repo with:

git clone git@ganesh:repositories/testing.git

instead of:

git@ganesh:testing.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    @VonC : Thanks for the answer. you are right about what I did. but when I try cloning repository using `git clone git@ganesh:testing.git` it gives **'testing.git does not appear to be a git repository'** I am not getting exactly what is wrong or how can I correct it. Can you give me some suggestions? Thanks – amar4kintu Mar 09 '11 at 05:07
  • @amar4kintu: just to be sure, what does `git clone git@ganesh:testing` returns? (so, cloning without the final '`.git`'). – VonC Mar 09 '11 at 05:11
  • 1
    @VonC : Thanks for reply again. it returns same error **'testing' does not appear to be a git repository** – amar4kintu Mar 09 '11 at 05:39
  • @amar4kintu: sorry for the delay, I had to get to work ;) Is your `.gitolite.rc` in the homedir of the git account? (where is it actually? What is its exact path?). What does `ssh git@ganesh` displays? – VonC Mar 09 '11 at 07:07
  • @VonC : Thanks for reply. I reinstalled gitolite and it seems that I am able to clone testing.git on my workstation pc using command `git clone gitolite:testing.git`. It works fine. Also I am able to commit and push origin master without any problem. But when I tried to do same thing on my server with command `git clone git@ganesh:testing.git` It gives **'testing.git' does not appear to be a git repository**. I also added ssh keys of administrator user in authorized_keys file of git user. – amar4kintu Mar 09 '11 at 08:46
  • @VonC : Also `ssh git@ganesh` produces following Administrator@ganesh ~ $ ssh git@ganesh Last login: Wed Mar 9 14:06:48 2011 from ganesh git@ganesh ~ $ – amar4kintu Mar 09 '11 at 08:55
  • @amar4kintu: I am not sure you should clone any repo with a user who ha direct ssh access: it should be with a user managed by gitolite. In other words, `ssh git@ganesh` should always answer (when you want to clone something): `hello user, the gitolite version here is... the gitolite config gives you the following access` – VonC Mar 09 '11 at 09:54
  • @VonC : Thanks for replying. I got your point and I searched for it. I got link (http://www.davedevelopment.co.uk/2010/12/05/how-to-install-gitolite-on-ubuntu-10-10-maverick-meerkat/) and (https://github.com/sitaramc/gitolite/blob/pu/doc/2-admin.mkd#_adding_users_and_repos) to create new user. I have id_rsa.pub for my user administrator@ganesh. I renamed it to newuser.pub and followed steps given but nothing happened. I create it with name newuser.pub because I have already file administrator.pub in clone of gitolite-admin/keydir on my workstation pc. Can you guide me further? – amar4kintu Mar 09 '11 at 12:51
  • @VonC : Is it compulsory to have username same as windows login user? Because normally in windows we have Administrator is used as user name and I want to give access to all my workstation users and most of them have login with username Administrator.. – amar4kintu Mar 09 '11 at 12:57
  • @amar4kintu: first of all, when dealing with ssh, there is no local username: your keys can refer to any user you want. One user can have several keys. The only "user" here is the one on the server side, where gitolite is installed. Second of all, I would really recommend to you the "**from client**" installation method (https://github.com/sitaramc/gitolite/blob/pu/doc/1-INSTALL.mkd#_from_client_method_install_from_the_client_to_the_server) documented here (http://sitaramc.github.com/gitolite/doc/install-transcript.html): make sure the pre-requisites are respected in term of ssh keys. – VonC Mar 09 '11 at 13:03
  • @VonC: Thanks for the reply. At last, I was able to make it proper. Actually in my authorized_keys file on server there was already key with ssh-rsa for my user... just before key with command = "" for gitolite user.. I remove key with ssh-rsa and it started working fine.. Again thanks for all your help.. and also I have already accepted your answer... – amar4kintu Mar 10 '11 at 07:17
  • @amar4kintu: you're most welcome. I am just glad you made it work in the end :) – VonC Mar 10 '11 at 07:30
2

Try to:

ssh git@ganesh

You should see gitolite-shell instead of bash:

ssh git@localhost

PTY allocation request failed on channel 0 hello
id_rsa, the gitolite version here is 2.0.3-2 (Debian) the gitolite
config gives you the following access:
     R   W  gitolite-admin
    @R_ @W_ testing
Connection to localhost closed.

If not it means you bypass gitolite-shell and use bash instead. The reason might be, that by running gl-setup your_pub_key.pub you added your key to the bottom of /home/git/.ssh/authorized_keys file.

Therefore, this key is never reached, because there are other keys at the top. So, you simply need to open /home/git/.ssh/authorired_keys and move the recently added gitolite key to the top of the file.

After moving this record to the top of the file, you should be able to use: git clone git@ganesh:testing.git insead of git clone git@ganesh:repositories/testing.git The second one clones the repo but leads to the error, because you run "git push" via bash instead of gitolite-shell

Kostyantyn
  • 5,041
  • 3
  • 34
  • 30
2

Just got the same error.

Correct answer is you need to use git clone gitolite:repo_name command to clone the repository and git push gitolite:repo_name to push changes, instead of git clone git@yourservername:repo_name.

sarnold
  • 102,305
  • 22
  • 181
  • 238
Alcherk
  • 21
  • 2
  • @simont: note that `**` bold doesn't work in code formatting. (It could be double-pointer indirection or exponentiation, or showing how to bold content in markdown, after all...) – sarnold Feb 18 '12 at 00:40
  • @sarnold I hadn't thought of that - noted. – simont Feb 18 '12 at 00:51
2

The ssh troubleshooting document at http://sitaramc.github.com/gitolite/doc/ssh-troubleshooting.html (as well as in the gitolite source repo) has been totally re-worked now. I'm hoping that it flows much better and explains things easier, including this specific error.

I'll also add that you should ideally read that document in full, at least the first time.

Sitaram

  • The link to the SSH troubleshooting document is now http://sitaramc.github.com/gitolite/sts.html – appas Jan 09 '12 at 08:44