5分钟搞定 Git 服务端 安装 windows 2003 gitblit

本文介绍了在Windows 2003环境下,如何在5分钟内利用Gitblit搭建Git服务端。Gitblit是一款开源的纯Java解决方案,适用于小团队托管集中式Git仓库。Gitblit GO提供了一种基于Jetty的单一栈解决方案,无需额外安装Apache、Perl、Git或Gitweb。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目准备使用Git,操作系统环境是windows 2003。阿里云的机器,不能再安装linux的虚拟机。搜索了一些资料,尝试了两种安装方法:


一、COPSSH+GIT 

安装成功后发现只能使用ssh,free版本的copssh只能一个用户连接,用户跟操作系统绑定,管理复杂度很高。
本来准备整合一下Apache 2.4试试,折腾到半途,各种不爽,决定放弃。

二、gitblit 
折腾git的过程中发现了gitblit这个工具,官方介绍如下(重点看介绍中的 5 mins.):

What is Gitblit?

Gitblit is an open-source, pure Java stack for managing, viewing, and serving Git repositories.
It's designed primarily as a tool for small workgroups who want to host centralized repositories.

GO: Single-Stack Solution

Gitblit GO is an integrated, single-stack solution based on Jetty.

You do not need Apache httpd, Perl, Git, or Gitweb. Should you want to use some or all of those, you still can; Gitblit plays nice with the other kids on the block.

This is what you should download if you want to go from zero to Git in less than 5 mins.


以下是安装过程,5分钟基本能搞定。
参考文档:

1、下载安装
官方地址:http://gitblit.com/
下载之后直接解压。
解压目录:C:\gitblit-1.7.1  目录结构如下:

2、The server itself is configured through a simple text file. 修改配置文件
Open data/gitblit.properties in your favorite text editor and make sure to review and set:
server.httpPort andserver.httpsPort
server.storePassword (do not enter # characters)
用notpad++打开 C:\gitblit-1.7.1\data\gitblit.properties,发现配件文件 include = defaults.properties
notpad++打开 C:\gitblit-1.7.1\data\defaults.properties 进行修改。
server.httpPort = 8080
server.httpsPort = 8443
server.storePassword = 123456 (这个是ssl的加密的密码,根据自己需要调整)
git.repositoriesFolder = D:/gits (这是git库的文件存放目录,根据自己需要进行调整)

https is strongly recommended because passwords are insecurely transmitted form your browser/git client using Basic authentication!
git.packedGitLimit (set larger than the size of your largest repository)
这个参数应该是性能优化的参数,默认10m,先使用默认的,后续再调整。

3、Execute authority.cmd or java -cp gitblit.jar com.gitblit.authority.Launcher --baseFolder data from a command-line
生成https的证书。(如果打算直接用http,那么此步骤可以不做)
NOTE: The Authority is a Swing GUI application. Use of this tool is not required as Gitblit GO will startup and create SSL certificates itself, BUT use of this tool allows you to control the identification metadata used in the generated self-signed certificates. Skipping this step will result in certificates with default metadata.
fill out the fields in the new certificate defaults dialog
enter the store password used in server.storePassword when prompted. This generates an SSL certificate for localhost.
you may want to generate an SSL certificate for the hostname or ip address hostnames you are serving from
NOTE: You can only have one SSL certificate specified for a port.
exit the authority app
3.1执行authority.cmd 证书生成界面
3.2点击新建按钮,出来以下界面,主机名填localhost
3.3输入keystore密码, 需要与配置文件的server.storePassword一致,本示例是123456
3.4点确定即可。如果密码输入不一致,会报Exception。

4、Execute gitblit.cmd or java -jar gitblit.jar --baseFolder data from a command-line
执行gitblit.cmd 启动服务器,使用的是jetty容器。启动之后就是一个cmd的窗口。
也可以执行installService.cmd把gitblit安装成windows的服务,这样就可以在服务的管理界面启动和关闭

5、Open your browser to http://localhost:8080 or https://localhost:8443 depending on your chosen configuration.
Enter the default administrator credentials: admin / admin and click the Login button
NOTE: Make sure to change the administrator username and/or password!!

在浏览器里面访问https://localhost:8443。
默认密码:admin/admin
登录之后第一件事情先修改密码。
到此服务器已经安装成功。
6、创建版本库,按步骤操作即可,确定之后会生成git初始化版本库的命令(Linux),以下我改成windows。
或者在创建版本库的时候勾选上自动创建文件.
    date /T > README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin ssh://admin@127.0.0.1:29418/test.git
    git push -u origin master
以上命令需要先在服务器上创建一个目录(只是临时使用,真正的版本库不是存放在这个目录),cmd到这个目录,然后执行。

7、客户端访问
7.1,http访问:http://admin@127.0.0.1:8080/r/test.git  。直接在命令行或者TortoiseGit都可以访问。
7.2,https访问:https://admin@127.0.0.1:8443/r/test.git
需要先在命令行下执行:
git config --global http.sslVerify false
否则会报错
fatal: unable to access 'https://******/r/test.git/': SSL certificate problem: self signed certificate in certificate chain



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值