windows 利用apache + git 搭建远程版本仓库

2017-3-13 aqi_wolf C++

需求:

    局域网内电脑代码同步管理

环境:

    mac osx/windows7

软件:

    wamp:安装php + http + mysql 开发环境

    git:git版本控制

步骤:参考http://blog.csdn.net/wangwei_cq/article/details/9379757

    第一步:安装wamp:傻瓜化一步步就可以

    第二步:安装git:基本也是傻瓜化看情况选择配置

    第三步:配置Apache服务器

进入Apache安装目录下的conf目录,打开httpd.conf文件,找到<directory />节点,修改如下:

<directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</directory>

然后在httpd.conf文件的末尾追加:

# Set this to the root folder containing your Git repositories.

# 指定 Git 版本库的位置

SetEnv GIT_PROJECT_ROOT C:/workspace

# 该目录下的所有版本库都可以透过 HTTP(S) 的方式存取

SetEnv GIT_HTTP_EXPORT_ALL

# Route specific URLS matching this regular expression to the git http server.

# 令 Apache 把 Git 相关 URL 导向给 Git 的 http 处理程序

ScriptAliasMatch \

"(?x)^/(.*/(HEAD | \

info/refs | \

objects/(info/[^/]+ | \

[0-9a-f]{2}/[0-9a-f]{38} | \

pack/pack-[0-9a-f]{40}\.(pack|idx)) | \

git-(upload|receive)-pack))$" \

"C:/Program Files/Git/libexec/git-core/git-http-backend.exe/$1"

#这边git-http-backend.exe安装路径又得时在c:/Program Files/Git/mingw64/libexec/git-core/git-http-backend.exe

<Location />

AuthType Basic

AuthName "GIT Repository"

AuthUserFile "C:/Program Files/Git/htpassword"

#密码需求,不需要可以注释掉

Require valid-user

</Location>

第四步:添加用户

进入Apache安装目录下的bin,执行

htpasswd -cmb htpassword abc 123456

把生成的htpassword放到c:/Program Files/Git(位置随意,跟上面的AuthUserFile对应就行)

第五步: 测试

进入c:/workspace 创建空版本库

git init --bare test.git

到目的电脑上执行命令上传版本

如:服务端ip为192.168.0.2

git push http://192.168.0.2/test.git master


标签: git apache

发表评论:

Powered by EMLOG Copyright @ 深圳市炽旗科技 版权所有. 闽ICP备14012694号-2