我已经使用SVN多年了,但我想第一次测试Git。
我尝试使用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返回以下消息:
您的配置指定与来自的“ref”master合并 远程,但没有提到这样的参考。
无论如何,我对我的代码一无所知。我稍后会尝试修复它。我们试着推送到服务器。
所以我做git push
。
没有共同的参考,没有指定;什么也不做 也许你应该指定一个分支,比如'master' 一切都是最新的
好的...... “什么都不做”但“一切都是最新的”?
经过一番检查后,我找到并执行了以下命令:git push origin master
这次我有以下消息:
错误:解包失败:unpack-objects异常退出
致http://git.mydomain.com/my_project.git
! [远程拒绝]主人 - &gt;主人(不适用(拆包商错误))
错误:未能将某些引用推送到“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
返回:
您的配置指定与来自的“ref”master合并 远程,但没有提到这样的参考。
和git push origin master
返回:
错误:解包失败:unpack-objects异常退出 至http://git.mydomain.com/my_project.git ! [远程拒绝]主人 - &gt; master(不适用(解包器错误)) 错误:未能将某些引用推送到“http://git.mydomain.com/my_project.git”
答案 0 :(得分:0)
我不知道这是否是答案,但我记得我有类似的问题,因为我没有安装cgi。所以我会以root或sudo的身份安装依赖项。 (我知道我正在用这个建议打死马。) 在Debian堆栈上的Ex:
#!/bin/sh
apt-get install git-core
apt-get install curl-ssl
a2enmod cgi
a2enmod alias
a2enmod env
您可能缺少apache cgi模块。理论上你的apache cfg文件看起来不错,但我也会尝试将这些脚本别名更改为实际名称而不是使用root只是为了确保服务器没有做任何疯狂的事情。但我和你在一起。我试图让Smart GIT HTTP在ubuntu服务器上运行。我让它继续使用Debian,但之前的Apache Rewrite Rules正在重定向网址。
我也不会使用git init --bare
。我至少会创建一个README文件,因此git可以创建一个HEAD。然后使用git init
,因为GIT已经标准化了一个.git /文件夹来保存信息。 git init --bare不会这样做。使用git log查看更改。
例如,这样做:
#!/bin/sh
echo >> '' README
git init
git add .
git commit
git log --oneline --decorate --graph