Git + Smart HTTP问题(不能推/拉) [英] Git + Smart HTTP problems (cannot push/pull)

查看:190
本文介绍了Git + Smart HTTP问题(不能推/拉)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了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
$ b $ 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>
选项+ ExecCGI + SymLinksIfOwnerMatch -MultiViews
AllowOverride无
从所有
开始允许,拒绝
允许< / Directory>

<位置/>
AuthType Basic
AuthNameGit Access
AuthUserFile / var / git / passwd
需要有效用户
< / Location>
< / VirtualHost>
EOF






  $ a2ensite git 
$ service apache2重新加载$ ​​b
$ b $ 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
这是一个测试
EOF
$ git add test-file.txt
$ git commit -m我的第一次提交



现在一切都好了。



我希望我的内容得到更新通过我的远程仓库,我做了 git pull ,但这不起作用。
Git返回以下消息:

lockquote

您的配置指定与
remote中的ref'master'合并,但没有这样的ref。


无论如何,我独自一人在我的代码上。我会稍后尝试修复它。让我们尝试推送到服务器。



所以我做 git push


没有共同的引用和没有指定;什么都不做。

也许你应该指定一个分支,比如'master'。

一切都是最新的


好的... 什么都不做但是一切都是最新的



经过一番检查,我发现并执行了下面的命令: git push origin master
这次我收到以下消息:


错误:解包失败:解包对象异常退出
http://git.mydomain.com/my_project.git

! [remote rejected] 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
$ b $ 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
AuthNameGit Access
AuthUserFile / var / git / passwd
需要有效用户
< / Location>

< / VirtualHost>

我有完全相同的错误。

git pull 返回:


您的配置指定与ref'master 'from
remote,但是没有这样的ref被获取。


git push origin master
$ b


错误:解包失败:解包对象异常退出
http://git.mydomain.com/my_project.git
! [remote rejected] master - > master(n / a(unpacker error))
错误:未能将一些文件推送到'http://git.mydomain.com/my_project.git'



解决方案

我不知道这是否是答案,但我记得我有类似的问题,因为我没有安装cgi 。所以我会以root或者sudo的方式安装依赖项。 (我知道我用这个建议击败了一匹死马)
在Debian堆栈中:

 #!/ bin / sh 

apt-get install git-core
apt-get install curl-ssl
a2enmod cgi
a2enmod别名
a2enmod env

您可能会缺少apache cgi模块。从理论上讲,你的apache cfg文件看起来不错,但我也会尝试将这些脚本别名改为实际名称,而不是仅仅使用根来确保服务器没有做任何疯狂的事情。但我和你在一起。我正试图让Smart GIT HTTP在ubuntu服务器上工作。我把它放在了Debian上,但之前的Apache Rewrite Rules重定向了url。



我也不会使用 git init --bare code>。我至少会创建一个自述文件,以便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


I've used SVN for years, but I want to test Git for the first time.

I tried to use HTTP protocol in order to keep my previous credentials (made with htpasswd).

I followed this procedure on my server:

$ 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

On my client, I do this:

$ 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"

Everything seems to be okay for now.

As I want my content to be updated by my remote repository, I do git pull, but this doesn't work. Git returns the following message :

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

Anyway, I'm alone on my code. I'll try to fix it later. Let's try to push to the server.

So I do git push.

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date

Okay... "doing nothing" but "Everything is up-to-date"?

After a little check, I find and execute, the following command : git push origin master This time I have the following message :

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'

I tried to follow many tutorials on the web.

I think my configuration is simple, so I can't understand why it doesn't work.

Thanks for anyone who can help me.

EDIT :

I restarted from scratch, following http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html

I don't need gitweb. I just want to use HTTP protocol with Git client.

So my virtualhost is :

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

I have exactly the same errors.

git pull returns :

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

and git push origin master returns :

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'

解决方案

I don't know if this is the answer but I remember I had similar problems because I did not install cgi. So I would install dependencies as root or sudo. (I know I am beating a dead horse with this suggestion. ) Ex on debian stack:

#!/bin/sh

apt-get install git-core
apt-get install curl-ssl
a2enmod cgi
a2enmod alias
a2enmod env

You may be missing the apache cgi module. In theory your apache cfg file looks good, but I would also try to changed those script aliases to an actual name instead of using the root just to make sure that the server isn't doing anything crazy. But I'm with you. I am trying to get Smart GIT HTTP to work on a ubuntu server. I got it going on a Debian, but previous Apache Rewrite Rules were redirecting urls.

I would also not use git init --bare. I would at least create a README File so git can create and a HEAD. Then use git init because GIT has standardized putting a .git/ folder to hold information. git init --bare does not do this. Use git log to view changes. For example do this:

#!/bin/sh

echo >> '' README
git init
git add .
git commit
git log --oneline --decorate --graph

这篇关于Git + Smart HTTP问题(不能推/拉)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆