使用Gitblit在windows上搭建私有Git服务器

目录

1 软件安装

1.1 java 环境配置

1.2 安装 GitBlit

2 GitBlit 配置

3 GitBlit 使用

3.1 添加 rsa 密钥

4 设置以Windows Service方式启动Gitblit

4.1 方法一

4.2 方法二


参考资料:

https://juejin.cn/post/6844903943458275341
https://www.pianshen.com/article/3892340872/
https://www.e-learn.cn/topic/3246779
https://www.imooc.com/article/292121

gitlab gitblit功能,使用对比如何?
    https://www.zhihu.com/question/28485788

需要安装的工具:Git、tortoiseGit、Gitblit

Java 库用来管理、查看和处理 Git 的资料库工具,相当于 Git 的 Java 管理工具。通俗点来说就是一个相当于 SVN 的工具,用于多个人共同开发同一个项目,共用资源的目的。

1 软件安装

Java SE 12.0.2 和JSC 直接按照指示安装即可,接着需要配置 Java 的环境。

右击我的电脑,点击属性,选择高级系统设置

1.1 java 环境配置

变量名变量值
JAVA_HOMEC:\Program Files\Java // 要根据自己的实际路径配置
Path%JAVA_HOME%\jdk-12.0.2\bin%JAVA_HOME%\jre1.8.0_221\bin

在终端输入 java 或者 havac 验证是否安装正确。

1.2 安装 GitBlit

首先从网上下载并安装最新版的 Git 与 vscode(用于编辑文档),其次从 Gitblit 官方网站:http://www.gitblit.com/ 下载最新版本。软件 GitBlit 是一个压缩包,解压后即可使用:

2 GitBlit 配置

使用 vscode 打开 GitBlit 软件根目录:

创建终端:

将 data/defaults.properties 复制到根目录,并重命名为 my.properties

$ cp data/defaults.properties my.properties

打开 data/gitblit.properties 文件,注释掉 include = defaults.properties 这句,添加 include = my.properties 这句,说明使用的是 my.properties 配置文件:

{% asset_img properties.png properties %}

在 my.properties 中查找 server.httpPort 并添加值:

接着修改 server.httpBindInterface 为 192.168.42.73(绑定的 IP 地址)。最后,在终端输入 .\gitblit.cmd,便可以启动 GitBlit 了。之后在浏览器输入地址:https://localhost:8443/ 便可以开启服务器,弹出一个警告窗口,直接选择 高级 并接受风险:

最终界面如下:

方法二:
直接修改data/gitblit.properties,不需要 my.properties,直接如下操作:

#
# GITBLIT.PROPERTIES
#
# Define your custom settings in this file and/or include settings defined in
# other properties files.
#

# Include Gitblit's 'defaults.properties' within your configuration.
#
# NOTE: Gitblit will not automatically reload "included" properties.  Gitblit
# only watches the 'gitblit.properties' file for modifications.
#
# Paths may be relative to the ${baseFolder} or they may be absolute.
#
# COMMA-DELIMITED
# SINCE 1.7.0
include = defaults.properties

#
# Define your overrides or custom settings below
#
git.repositoriesFolder = D:/GitServer 
server.httpPort = 10101     
server.httpBindInterface = 192.168.42.30
server.httpsBindInterface = localhost
server.httpsPort = 8443
server.certificateAlias = localhost
  • git.repositoriesFolder:服务器地址(最好不要有中文和空格)
  • server.httpPort:http 端口号
  • server.httpBindInterface:http IP 地址

3 GitBlit 使用

启动 gitblit 界面,在左上角有个登录框,初始值用户名和密码均为 admin,然后便可以添加用户和团队并设置其权限:

3.1 添加 rsa 密钥

选择用户中心

在 SSH Key 栏可以看到一个空白的输入框,其内容可以通过如下方式获取:

  1. 再次添加一个终端并在终端输入:
$ ssh-keygen -t rsa # 生成密钥
$ cat ~/id_rsa.pub  # 查看密钥

便可以获取本地使用的 rsa 密钥,复制到 SSH Key 框中,点击 添加 按钮即可。

4 设置以Windows Service方式启动Gitblit

4.1 方法一

前面我们是以运行gitblit.cmd的方式启动Gitblit的,如果不想每次开机都去双击执行它,跟随系统自启岂不是美哉。下面我们看怎么实现。

  1. 打开installService.cmd文件 文件位于根目录下。我的是D:\gitblit-1.8.0\installService.cmd ,用EditPlus或者记事本打开。
  2. 编辑installService.cmd文件
#修改ARCH,32位系统:SET ARCH=x86,64位系统:SET ARCH=amd64
SET ARCH=amd64
#添加 CD 为程序目录
SET CD=D:\gitblit-1.8.0
#修改StartParams里的启动参数,给空就可以了。
 --StartParams="" ^
复制代码
  1. 保存
  2. 以管理员身份运行installService.cmd文件。
  3. 在计算机-管理-服务下,就能看到已经存在的gitblit服务了。

4.2 方法二

gitbilt 作为服务启动

  1. 编辑installService.cmd文件
  2. 查找SET ARCH 系统32则设置为x86 64位则设置为amd64
  3. 设置CD为程序目录
  4. 查找 --StartParams 设置为“”

 

Gitbilt作为服务启动测试

  1. 以管理员身份运行 installService.cmd
  2. 打开服务中心查找gitbilt ,启动后 访问上述页面;
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值