我已经使用了SVN多年,但我想第一次测试Git。Git +智能HTTP问题(无法推/拉)
我试图使用HTTP协议,以保持我以前的凭据(使用htpasswd
)。
我跟着我的服务器上执行此过程:
$ aptitude install git-core apache2
$ mkdir -p /var/git/repositories
$ htpasswd -c /var/git/passwd my_account
$ cat > /etc/apache2/sites-available/git << EOF
<VirtualHost *:80>
ServerName git.mydomain.com
SetEnv GIT_PROJECT_ROOT /var/git/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias//usr/lib/git-core/git-http-backend/
DocumentRoot /var/git/repositories
<Directory /var/git/repositories>
Options +ExecCGI +SymLinksIfOwnerMatch -MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Location />
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/git/passwd
Require valid-user
</Location>
</VirtualHost>
EOF
$ a2ensite git
$ service apache2 reload
$ cd /var/git/repositories
$ git init --bare my_project.git
$ git update-server-info
在我的客户,我这样做:
$ git clone http://git.mydomain.com/my_project.git
$ cd my_project
$ cat > test-file.txt << EOF
This is a test
EOF
$ git add test-file.txt
$ git commit -m "My first commit"
一切似乎现在是好的。
因为我希望我的内容能够通过远程存储库进行更新,所以我做了git pull
,但这不起作用。 的Git返回以下消息:
Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.
不管怎样,我独自一人在我的代码。我会稍后尝试修复它。我们尝试推送到服务器。因此我做git push
。
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date
好了... “无为”但“一切都取决于最新的”?
一点点检查后,我发现,执行下面的命令:git push origin master
这一次,我有以下消息:
error: unpack failed: unpack-objects abnormal exit
To http://git.mydomain.com/my_project.git
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'http://git.mydomain.com/my_project.git'
我试图按照网络上很多教程。
我觉得我的配置很简单,所以我不明白为什么它不起作用。
感谢任何能够帮助我的人。
编辑:
我从头开始重新启动,以下http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html
我不需要的GitWeb。我只想用Git客户端使用HTTP协议。
所以我的虚拟主机是:
<VirtualHost *:80>
ServerName git.mydomain.com
SetEnv GIT_PROJECT_ROOT /var/git/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias//usr/lib/git-core/git-http-backend/
DocumentRoot /var/git/repositories
<Location />
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/git/passwd
Require valid-user
</Location>
</VirtualHost>
我有完全相同的错误。
git pull
回报:
Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.
和git push origin master
回报:
error: unpack failed: unpack-objects abnormal exit To http://git.mydomain.com/my_project.git ! [remote rejected] master -> master (n/a (unpacker error)) error: failed to push some refs to 'http://git.mydomain.com/my_project.git'
如果您不使用密码/加密密码,会发生什么情况?作为一个方面说明,不会ssh就够了吗? – Shahbaz
SSH可能够用了,但对于SSH,我应该使用“系统”帐户而不是简单列表或数据库中的帐户,对吧? 如果我只是使用SSH,这个协议将使用户能够连接和执行命令。 – antoine
我用更简单的方式更新了线程来安装GIT服务器。 但它还没有工作。 – antoine