Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7401445
  • 博文数量: 1756
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16232
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1756)

文章存档

2024年(2)

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: WINDOWS

2011-11-15 17:27:48

一直打算用git,因为总感觉在本地仓库中交换信息,比svn这种大量信息仅存于服务器要快一些;但是服务器是Windows的,没有ssh,于是我打算在Windows上实现Git over HTTP。
实际上是给Apache配置一个WebDAV而已。期间遇到一些问题,通过goole得以解决,这里做一些总结。

第一部分:正常的流程,可以顺利完成的。

一、规划
1、服务器上无需工作目录,所以直接存储GIT的“库”(我不知道该如何称呼为妥):
C:/git-repos/project-name.git/

2、webDAV用到的认证文件
C:/git-repos/s6-passwd.txt

3、外部公开的版本库地址


二、配置Apache。编辑Conf/httpd.conf,加入以下信息:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

Alias /project-name.git "C:/git-repos/project-name.git/"

# 重要
DavLockDB C:/git-repos/DavLock


    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    DAV on
    AuthType Basic
    AuthName "Our Project Git Repos"
    AuthUserFile C:/git-repos/s6-passwd.txt

   
        Require valid-user
   



三、生成认证文件
C:\git-repos\project-name.git>X:\apache\bin\htpasswd -bm C:\git-repos\project-name-passwd.txt firstUserName FirstUserPassword

四、创建空的版本库

C:\git-repos\project-name.git>git --bare init
Initialized empty Git repository in C:/git-repos/project-name.git/

这一步不可缺少
C:\git-repos\project-name.git>git update-server-info

至此服务器上的配置完成;

五、客户端clone:

Z:\>git clone
Initialized empty Git repository in Z:/project-name/.git/
warning: You appear to have cloned an empty repository.

Z:\project-name>git pull origin master
Your configuration specifies to merge the ref 'master' from the
remote, but no such ref was fetched.

Z:\project-name>git push "origin" master:master
Fetching remote heads...
  refs/
  refs/heads/
  refs/tags/
updating 'refs/heads/master'
  from 0000000000000000000000000000000000000000
  to   f858916d97486a3b6435c7e4dfbe52fa082360db
    sending 5 objects
    done
Updating remote server info

全部顺利完成。


第二部分:遇到的问题及解决办法。

错误一、可以clone版本库,但无法提交,提示信息类似:

Z:\source>git push
error: Cannot access URL /, return code 22
error: failed to push some refs to ''

Z:\source>git pull origin master
error: Failed connect to No error while accessing /info/refs

fatal: HTTP request failed

同时,可以再Apache的错误日志中发现,类似这样的错误信息:

The lock database could not be opened, preventing access to the various lock properties for the PROPFIND.  [500, #0]
A lock database was not specified with the DAVLockDB directive. One must be specified to use the locking functionality.  [500, #401]


解决方法:

在Apache配置文件中,增加一行,设定webDAV锁位置
DavLockDB C:/git-repos/DavLock

错误二、无法提交,错误提示类似

Z:\project-name>git push
Fetching remote heads...
  refs/
  refs/heads/
  refs/tags/
No refs in common and none specified; doing nothing.

Z:\project-name>git pull origin master
fatal: Couldn't find remote ref master

解决方法:
Z:\project-name>git push "origin" master:master

错误三、无法提交,错误提示类似

Z:\project-name>git push "origin" master:master
error: Cannot access URL /, return code 7
error: failed to push some refs to ''

原因:
在服务器上运行命令 git update-server-info 之前clone的版本库

解决办法:
Z:\project-name>git pull


参考:


http://www.wretch.cc/blog/michaeloil/22286355   中文,需翻墙

转:http://alan-chengdu.blogspot.com/2010/08/windowshttpgit.html
阅读(3276) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~