一直打算用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.txt3、外部公开的版本库地址二、配置Apache。编辑Conf/httpd.conf,加入以下信息:LoadModule dav_module modules/mod_dav.soLoadModule dav_fs_module modules/mod_dav_fs.soAlias /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 initInitialized 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 masterYour configuration specifies to merge the ref 'master' from theremote, but no such ref was fetched.Z:\project-name>git push "origin" master:masterFetching remote heads... refs/ refs/heads/ refs/tags/updating 'refs/heads/master' from 0000000000000000000000000000000000000000 to f858916d97486a3b6435c7e4dfbe52fa082360db sending 5 objects doneUpdating remote server info全部顺利完成。第二部分:遇到的问题及解决办法。错误一、可以clone版本库,但无法提交,提示信息类似:Z:\source>git pusherror: Cannot access URL /, return code 22error: failed to push some refs to ''Z:\source>git pull origin mastererror: Failed connect to No error while accessing /info/refsfatal: 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 pushFetching remote heads... refs/ refs/heads/ refs/tags/No refs in common and none specified; doing nothing.Z:\project-name>git pull origin masterfatal: Couldn't find remote ref master解决方法:Z:\project-name>git push "origin" master:master错误三、无法提交,错误提示类似Z:\project-name>git push "origin" master:mastererror: Cannot access URL /, return code 7error: 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
阅读(3387) | 评论(0) | 转发(0) |