gpt4 book ai didi

Git + 智能 HTTP 问题(无法推送/pull )

转载 作者:太空狗 更新时间:2023-10-29 14:24:28 25 4
gpt4 key购买 nike

我已经使用 SVN 多年,但我想第一次测试 Git。

我尝试使用 HTTP 协议(protocol)来保留我以前的凭据(使用 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 协议(protocol)。

所以我的虚拟主机是:

<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'

最佳答案

我不知道这是否是答案,但我记得我遇到过类似的问题,因为我没有安装 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 文件看起来不错,但我也会尝试将这些脚本别名更改为实际名称,而不是使用根目录,只是为了确保服务器没有做任何疯狂的事情。但我和你在一起。我正在尝试让 Smart GIT HTTP 在 ubuntu 服务器上工作。我在 Debian 上运行它,但以前的 Apache 重写规则正在重定向 url。

我也不会使用 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

关于Git + 智能 HTTP 问题(无法推送/pull ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11193479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com