`
tangay
  • 浏览: 94652 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

git over http

 
阅读更多

 

中文请参考:

http://blog.longwin.com.tw/2009/05/build-git-env-over-http-2009/

 

Since Apache is one of those packages people like to compile
themselves while others prefer the bureaucrat's dream Debian, it is
impossible to give guidelines which will work for everyone. Just send
some feedback to the mailing list at git@vger.kernel.org to get this
document tailored to your favorite distro.


What's needed:

- Have an Apache web-server

On Debian:
$ apt-get install apache2
To get apache2 by default started,
edit /etc/default/apache2 and set NO_START=0

- can edit the configuration of it.

This could be found under /etc/httpd, or refer to your Apache documentation.

On Debian: this means being able to edit files under /etc/apache2

- can restart it.

'apachectl --graceful' might do. If it doesn't, just stop and
restart apache. Be warning that active connections to your server
might be aborted by this.

On Debian:
$ /etc/init.d/apache2 restart
or
$ /etc/init.d/apache2 force-reload
(which seems to do the same)
This adds symlinks from the /etc/apache2/mods-enabled to
/etc/apache2/mods-available.

- have permissions to chown a directory

- have git installed at the server _and_ client

In effect, this probably means you're going to be root.


Step 1: setup a bare GIT repository
-----------------------------------

At the time of writing, git-http-push cannot remotely create a GIT
repository. So we have to do that at the server side with git. Another
option would be to generate an empty repository at the client and copy
it to the server with WebDAV. But then you're probably the first to
try that out :)

Create the directory under the DocumentRoot of the directories served
by Apache. As an example we take /usr/local/apache2, but try "grep
DocumentRoot /where/ever/httpd.conf" to find your root:

$ cd /usr/local/apache/htdocs
$ mkdir my-new-repo.git

On Debian:

$ cd /var/www
$ mkdir my-new-repo.git


Initialize a bare repository

$ cd my-new-repo.git
$ git --bare init


Change the ownership to your web-server's credentials. Use "grep ^User
httpd.conf" and "grep ^Group httpd.conf" to find out:

$ chown -R www.www .

On Debian:

$ chown -R www-data.www-data .


If you do not know which user Apache runs as, you can alternatively do
a "chmod -R a+w .", inspect the files which are created later on, and
set the permissions appropriately.

Restart apache2, and check whether http://server/my-new-repo.git gives
a directory listing. If not, check whether apache started up
successfully.


Step 2: enable DAV on this repository
-------------------------------------

First make sure the dav_module is loaded. For this, insert in httpd.conf:

LoadModule dav_module libexec/httpd/libdav.so
AddModule mod_dav.c

Also make sure that this line exists which is the file used for
locking DAV operations:

DAVLockDB "/usr/local/apache2/temp/DAV.lock"

On Debian these steps can be performed with:

Enable the dav and dav_fs modules of apache:
$ a2enmod dav_fs
(just to be sure. dav_fs might be unneeded, I don't know)
$ a2enmod dav
The DAV lock is located in /etc/apache2/mods-available/dav_fs.conf:
DAVLockDB /var/lock/apache2/DAVLock

Of course, it can point somewhere else, but the string is actually just a
prefix in some Apache configurations, and therefore the _directory_ has to
be writable by the user Apache runs as.

Then, add something like this to your httpd.conf


DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /usr/local/apache2/conf/passwd.git
Require valid-user


On Debian:
Create (or add to) /etc/apache2/conf.d/git.conf :


DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /etc/apache2/passwd.git
Require valid-user


Debian automatically reads all files under /etc/apach2/conf.d.

The password file can be somewhere else, but it has to be readable by
Apache and preferably not readable by the world.

Create this file by
$ htpasswd -c /usr/local/apache2/conf/passwd.git

On Debian:
$ htpasswd -c /etc/apache2/passwd.git

You will be asked a password, and the file is created. Subsequent calls
to htpasswd should omit the '-c' option, since you want to append to the
existing file.

You need to restart Apache.

Now go to http://@/my-new-repo.git in your
browser to check whether it asks for a password and accepts the right
password.

On Debian:

To test the WebDAV part, do:

$ apt-get install litmus
$ litmus http:///my-new-repo.git

Most tests should pass.

A command line tool to test WebDAV is cadaver.

If you're into Windows, from XP onwards Internet Explorer supports
WebDAV. For this, do Internet Explorer -> Open Location ->
http:///my-new-repo.git [x] Open as webfolder -> login .


Step 3: setup the client
------------------------

Make sure that you have HTTP support, i.e. your git was built with curl.
The easiest way to check is to look for the executable 'git-http-push'.

Then, add the following to your $HOME/.netrc (you can do without, but will be
asked to input your password a _lot_ of times):

machine
login
password

...and set permissions:
chmod 600 ~/.netrc

If you want to access the web-server by its IP, you have to type that in,
instead of the server name.

To check whether all is OK, do:

curl --netrc --location -v http://@/my-new-repo.git/

...this should give a directory listing in HTML of /var/www/my-new-repo.git .


Now, add the remote in your existing repository which contains the project
you want to export:

$ git-config remote.upload.url \
http://@/my-new-repo.git/

It is important to put the last '/'; Without it, the server will send
a redirect which git-http-push does not (yet) understand, and git-http-push
will repeat the request infinitely.


Step 4: make the initial push
-----------------------------

From your client repository, do

$ git push upload master

This pushes branch 'master' (which is assumed to be the branch you
want to export) to repository called 'upload', which we previously
defined with git-config.


Troubleshooting:
----------------

If git-http-push says

Error: no DAV locking support on remote repo http://...

then it means the web-server did not accept your authentication. Make sure
that the user name and password matches in httpd.conf, .netrc and the URL
you are uploading to.

If git-http-push shows you an error (22/502) when trying to MOVE a blob,
it means that your web-server somehow does not recognize its name in the
request; This can happen when you start Apache, but then disable the
network interface. A simple restart of Apache helps.

Errors like (22/502) are of format (curl error code/http error
code). So (22/404) means something like 'not found' at the server.

Reading /usr/local/apache2/logs/error_log is often helpful.

On Debian: Read /var/log/apache2/error.log instead.


Debian References: http://www.debian-administration.org/articles/285

Authors
Johannes Schindelin
Rutger Nijlunsing

分享到:
评论

相关推荐

    pro git 完整、完美中文版...

    - Git-over-SSH: 基于SSH的安全传输。 **9.7 维护及数据恢复** - **命令**: - `git fsck`: 检查数据完整性。 - `git gc`: 清理未引用的对象。 **9.8 总结** - **总结**: 深入探讨了Git的内部机制,包括对象...

    Git-2.21.0-64-bit.zip

    Git-2.21.0-64 for windows Git 2.23 Release Notes ====================== Updates since v2.22 ------------------- Backward compatibility note * The "--base" option of "format-patch" computed the ...

    Git文件缓存分离组件Gitsym.zip

    .git-bisect works properly even when versions of the binary files change over time. (We recommend installing a git-sym-post-checkout-hook, in case the resources have not been cached already.)selective...

    http-over-all:通过http端点访问各种资源(nfs,smb,ssh,httpdav,git,docker)的统一接口

    全部HTTP 通过http端点访问各种资源(nfs,smb,ssh,http / dav,git,docker)的统一接口。 集成始终提供最新内容的代理。 在不同的层上启用访问限制。 HTTP:基本身份验证,IP地址资源:每资源acl安装/运行拉最新...

    Go-用于GoogleDNS-over-HTTPS的DNS协议代理

    "fardog"可能是指项目的名称,"secureoperator"可能是指该代理软件的角色或功能,即确保安全的DNS操作,而"0b2d881"则可能是Git仓库中的一个提交哈希值,用于标识代码的某个特定状态。 在Go中实现DNS-over-HTTPS...

    在CentOS7上搭建Jenkins+Maven+Git持续集成环境的方法

    需要安装Publish Over SSH、Maven Integration以及Git Plugins(已默认安装)插件。在“Manage Jenkins” -> “Manage Plugins”中搜索并安装。配置SSH免密码登录,这通常涉及到在本地生成SSH密钥对,并将公钥添加...

    asterisk-gui:AsteriskGUI 项目的 Git 仓库

    Asterisk是全球最广泛使用的开源通信平台,它支持VoIP(Voice over Internet Protocol)电话、会议、即时消息等多种通信功能。Asterisk GUI则是为了让用户更方便地配置和管理Asterisk服务器而开发的。 Git仓库是...

    gitlab-shell:替代乙醇钠矿。 此仓库是https的镜像

    GitLab外壳 GitLab Shell为GitLab处理git SSH会话 GitLab Shell为GitLab处理git SSH会话并修改授权密钥列表... git over SSH-> gitlab-shell-> API调用gitlab-rails(Authorization)->接受或拒绝->建立Gitaly会话 git

    godoh::hole:godoh-HTTP-over-HTTPS C2

    要从源代码构建godoh ,请执行以下步骤: 确保您拥有Go 1.13+ 使用git clone https://github.com/sensepost/goDoH.git克隆此存储库运行生成make key以生成用于通信的唯一加密密钥使用以下选项之一构建项目: go ...

    sh-over-avs-demo

    先决条件: ...运行git clone https://github.com/romaneul/sh-over-avs-demo.git cd sh-over-avs-demo npm install 更新.env文件: LWA_CLIENT_ID= LWA_CLIENT_SECRET=<LWA Client Secret from

    linphone api

    林手机(Linphone)是一款开源的VoIP(Voice over Internet Protocol)软件,它提供了跨平台的语音、视频通话以及即时消息功能。本文将深入探讨“linphone API”及其在3.4.3版本中的网页格式压缩特性。 ### 1. ...

    lwip源码(小型TCP/IP协议栈)

    http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git Submit patches and bugs via the lwIP project page: http://savannah.nongnu.org/projects/lwip/ Continuous integration builds (GCC, clang): ...

    Android代码-Android同网段设备扫描

    Machines discovery/mapping (over Wifi) and port scan (over 3G/Wifi) utility for Android devices. Features Discover Machines on a LAN (connect/ping discovery, dns discovery) TCP Port Scanner (connect...

    jenkins 相关配置 1

    总结,Jenkins 的配置涉及 SSH 密钥管理、Publish Over SSH 插件、Git 集成、SVN 命令以及增量发布策略,这些都对于自动化持续集成和持续部署流程至关重要。正确配置这些元素能确保高效、安全的自动化流程。

    基于strophe.js的web聊天

    strophe.js通过BOSH(Bidirectional-streams Over Synchronous HTTP)技术解决了JavaScript在浏览器端无法持久连接的问题,使得Web应用可以实现类似原生应用的实时通信。 **2. BOSH服务与跨域问题** BOSH服务是...

    ONVif C++开发类库源码

    2. **网络编程**:ONVIF协议涉及网络通信,因此理解TCP/IP协议、HTTP和SOAP(Simple Object Access Protocol)是必要的,因为ONVIF服务通常基于SOAP over HTTP。 3. **XML解析**:由于ONVIF使用XML来传输数据,熟悉...

    JenKins安装及配置[归纳].pdf

    例如,为了本地环境的搭建,可能需要安装Git plugin、Deploy to container plugin 和 Publish Over SSH等插件。通过插件管理界面,输入插件名称进行搜索并安装。 4. **构建项目配置**: - **构建爬虫工作节点job**...

    C++ HTTP Reset32

    7. **安全考虑**:HTTPS(HTTP over TLS/SSL)对于敏感数据传输的重要性,以及如何在C++中实现加密通信。 8. **调试与测试**:使用工具(如Wireshark)抓包分析HTTP流量,以及编写单元测试确保HTTP库的正确性。 9....

Global site tag (gtag.js) - Google Analytics