现在的位置: 首页 > 综合 > 正文

Windows 下搭建 Git Server

2017年10月22日 ⁄ 综合 ⁄ 共 1249字 ⁄ 字号 评论关闭

参考 http://www.devbean.info/2011/10/apache-git-server-on-windows/

用 Apache + mysysGit

第一步:安装 mysysGit , Tortoise Git (略)

第二步:安装 Apache Http Server (略)

第三步:配置 Apache

----编辑 httpd.conf

修改:

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

# Set this to the root folder containing your Git repositories.
# 指定 Git 版本库的位置

SetEnv GIT_PROJECT_ROOT "F:/Git_Repo"

# Set this to export all projects by default (by default,
# git will only publish those repositories that contain a
# file named "git-daemon-export-ok"
# 该目录下的所有版本库都可以透过 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)^/git/(.*/(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))$" \
"D:/Program Files/Git/libexec/git-core/git-http-backend.exe/$1"

<Location /git>
AuthType Basic
AuthName "GIT Repository"
# 指定用户名密码文件的位置
AuthUserFile "D:/Program Files/Git/htpassword" 

Require valid-user
</Location>

第四步:创建用户

使用命令提示符来到 Apache 的 bin 目录,执行:

htpasswd -cmbfilename username password

生成一个名为 filename 的用户名密码文件,拷贝到 http.conf 中指定的路径



第五步:测试

1、来到目录 F:/Git_Repo下,创建版本库

    可以在 cmd 中执行 git -init --bare testrepo; 或者用 TortoiseGit 右键创建

2、用 TortoiseGit clone 版本库,http://localhost/git/Test_repo

抱歉!评论已关闭.