当前位置:文档之家› Gitblit搭建及Git协作开发流程参考

Gitblit搭建及Git协作开发流程参考

1 / 34 Gitblit搭建及Git协作开发流程 版本:v1.0(2015年3月20日) 作者:南瓜剪子

1. 概述 目前主流的是git作为自己代码管理,但是采用github需要付费才能够使用,如果不付费,代码需要公开。创业团队及小型开发团队都有必要搭建自己的代码服务器,自己摸索需要一定的时间,会赶不及项目进度。在此作者把自己的经验作为文档写下来,方便互联网各位创业者参考,能很快的搭建自己所需要的代码服务器。 同时作者也把最基本的开发流程,代码提交,代码上传,代码merge等流程用命令写出,方便大家参考。作者自己的团队开发以Maven+Java为主,使用eclipse作为开发工具,相关部分在此文档中都有详细的描述。 文档中使用的工具版本如下 jdk1.8.0_73 Gitblit 1.7.1 Eclipse MARS.1 PortableGit 2.7.1 Apache-maven-3.3.9 注意: 由于互联网技术日新月异,以后工具如有更新,流程也许会变化,所以本文档中流程只作为参考。

并请准备一台Windows机器,并且在你的局域网内,开发者能够访问 注意: 如果你只是一个开发者,不需要关心Gitblit代码服务器搭建,请跳过下面章节 第3章Gitblit服务器搭建 第4章配置Gitblit用户 第5章创建第一个Gitblit版本库 第7章项目管理者上传项目最初始代码 这几张是有关Gitblit部分,主要是代码管理员需要学习服务器管理。开发人员请从后面相关部分学习,后面类容依然精彩,会告诉你怎么下载代码,构建工程,还有上传代码,更新代码。

2. 安装JDK 安装JDK这个过程我就不再过多描述 访问 2 / 34

下载最新JDK,并按操作安装 安装完毕后最好设置环境变量JAVA_HOME及PATH 新建JAVA_HOME=C:\Program Files\Java\jdk1.8.0_73 (你的JDK安装目录,请核对你自己目录及版本) 并把(;%JAVA_HOME%\bin;)加入到PATH

大致流程如下图所示

3. Gitblit服务器搭建 访问地址: 下载最新的Gitblit windows版本,由于小型团队一般以windows机器为主,在这里只介绍windows版本的搭建

Step1) 下载gitblit-1.7.1.zip

Step2) 解压到D:\open_source\gitblit-1.7.1

Step3) 创建一个目录,用来存放代码库:D:/GitRepositoies

Step4) 修改data目录下的gitblit.properties (D:\open_source\gitblit-1.7.1\data\gitblit.properties) 加入以下红色内容 # # GITBLIT.PROPERTIES # # Define your custom settings in this include settings defined in # other properties files. # 3 / 34

# Include Gitblit's 'defaults.properties' within your configuration. # # NOTE: Gitblit will not automatically reload "included" properties. Gitblit # only watches the 'gitblit.properties' 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 #

# Base folder for repositories. # This folder may contain bare and non-bare repositories but Gitblit will only # allow you to push to bare repositories. # Use forward slashes even on Windows!! # e.g. c:/gitrepos # # SINCE 0.5.0 # RESTART REQUIRED # BASEFOLDER git.repositoriesFolder = D:/GitRepositoies

# Standard http port to serve. <= 0 disables this connector. # On Unix/Linux systems, ports < 1024 require root permissions. # Recommended value: 80 or 8080 # # SINCE 0.5.0 # RESTART REQUIRED server.httpPort = 1000

# Secure/SSL https port to serve. <= 0 disables this connector. # On Unix/Linux systems, ports < 1024 require root permissions. # Recommended value: 443 or 8443 # # SINCE 0.5.0 # RESTART REQUIRED server.httpsPort = 1001

# Specify the interface for Jetty to bind the standard connector. # You may specify an ip or an empty value to bind to all interfaces. 4 / 34

# Specifying localhost will result in Gitblit ONLY listening to requests to # localhost. # # SINCE 0.5.0 # RESTART REQUIRED server.httpBindInterface =

# Specify the interface for Jetty to bind the secure connector. # You may specify an ip or an empty value to bind to all interfaces. # Specifying localhost will result in Gitblit ONLY listening to requests to # localhost. # # SINCE 0.5.0 # RESTART REQUIRED server.httpsBindInterface = 注意:红色部分属性都是从同目录下defaults.properties拷贝过来,只是采用了我们自己的配置,其中为了安全及便利,我没有没有使用端口 80及443,用1000及1001代替(因为我团队的机器80端口用作其他用途了)。并把仓库设置为Step3中的目录。

Step5) 修改D:\open_source\gitblit-1.7.1\installService.cmd下面红色部分 @REM Install Gitblit as a Windows service.

@REM gitblitw.exe (prunmgr.exe) is a GUI application for monitoring @REM and configuring the Gitblit procrun service. @REM @REM By default this tool launches the service properties dialog @REM but it also has some other very useful functionality. @REM @REM

@REM arch = x86, amd64, or ia32 SET ARCH=x86 由于我的机器是x86-32位的,所以我改为x86,请对照你机器的架构选择 如果你的机器是64位,请选择amd64

Step6) 安装windows服务 用管理员权限打开CMD命令提示符,如下图所示 5 / 34

然后再命令行中输入一下命令 C:\Windows\system32>d: D:\>cd D:\open_source\gitblit-1.7.1 D:\open_source\gitblit-1.7.1>installService

Step7) 检查windows服务 开始菜单“运行”中,输入services.msc 并检查gitblit服务是否成功安装,由于开发团队每天都在用,确保为自动模式,每次windows启动都自动启动

相关主题