1) 问题1
我的默认gitolite管理员用户称为“git”,已经创建好了。
首先,我必须克隆gitolite-admin存储库,进行一些更改,例如在conf/gitolite.conf中添加一些新存储库和新用户(我添加了root用户,并且我之前创建了私钥/公钥,并将公钥添加到keydir文件夹中),然后我必须添加/提交并推送更改回来。
信息:我的~git/.ssh/authorized_keys文件很好,以command=开头,只有一个值-我最初创建的git用户的公钥。
未能生效:
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
完成:
touch ~/.ssh/config
关于IT技术的翻译:
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.
为什么第一种方法完全不起作用?所有的教程都说它应该没有任何问题。我不得不使用第二种方法,在~/.ssh/config文件中创建主机配置。这有点令人沮丧。仓库路径是/home/git/repositories,ssh默认端口为22。
2) 问题2
在同一台服务器上使用root用户,在/var/www/example.com/www中创建了一个空文件夹。我运行了git init,然后添加了一个文件(.gitignore),运行git add -A和git commit -m“...”。
然后我创建了远程路径origin:
git remote add origin git@<<SERVER_IP>>:myrepo.git
我运行了git push origin master,得到了以下结果:
fatal: 'myrepo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
我尝试了各种方法来进行更改,例如将整个存储库路径放入其中(即使我在任何地方都没有看到过,因此这是不正确的),结果出现了以下错误:
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'
我做错了什么?这个基本任务让我感到非常沮丧,因为我遇到了不寻常的困难。我在使用SVN方面有很丰富的经验,但这是我第一次使用GIT。
非常感谢您的帮助!
fatal: 'myrepo.git' does not appear to be a git repository
) 意味着你的 pubkey (用于 root) 绕过了 gitolite 直接进入 shell (再次参考 http://sitaramc.github.com/gitolite/sts.html#ssh_troubleshooting_common_ssh_problems_)。 - VonC