我已经使用 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' 合并,但没有获取这样的 ref。
无论如何,我一个人在我的代码上。我稍后会尝试修复它。让我们尝试推送到服务器。
所以我愿意git push
。
没有共同的参考文献,也没有指定;什么也不做。
也许您应该指定一个分支,例如“master”。
一切都是最新的
好吧...... “什么都不做”但“一切都是最新的”?
经过一番检查,我找到并执行了以下命令:git push origin master
这次我有以下消息:
error: unpack failed: unpack-objects 异常退出
到http://git.mydomain.com/my_project.git
![远程拒绝] master -> master (n/a (unpacker error))
错误:未能将一些参考推送到“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' 合并,但没有获取这样的 ref。
并git push origin master
返回:
error: unpack failed: unpack-objects 异常退出到http://git.mydomain.com/my_project.git ![远程拒绝] master -> master (n/a (unpacker error)) 错误:未能将一些参考推送到“http://git.mydomain.com/my_project.git”