栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

在win平台上使用gitblit去建立git服务,并在ubuntu上进行git操作

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在win平台上使用gitblit去建立git服务,并在ubuntu上进行git操作

关键词:java, git ,windows, linux ,局域网git

一.安装Java

下载地址:https://www.java.com/zh-CN/

配置java环境变量

路径:“电脑” -> “属性” -> “高级系统设置” -> “高级” -> “环境变量” 中的“系统变量”。

  1. 新建JAVA_HOME
    变量名:JAVA_HOME
    变量值:根据自身的安装路径

  2. 新建CLASSPATH
    变量名:CLASSPATH
    变量值:% JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar

  3. 添加Path变量

二.建立Gitblit服务
  1. 下载地址:http://gitblit.github.io/gitblit/
  2. 解压下载的包,无需安装,但路径最好如下图所示。
  3. 在D盘下创建33.git的文件夹,并进入gitblit-1.8.0data,编辑defaults.properties文件,填写仓库存储路径地址,并修改server.httpPort,server.httpsPort,server.httpBindInterface,server.httpBindInterface,server.certificateAlias。其中httpPort和httpsPort是端口号,httpBindInterface是你电脑本机ip地址。
# 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 = 80

# 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 = 83

# Automatically redirect http requests to the secure https connector.
#
# This setting requires that you have configured server.httpPort and server.httpsPort.
# Unless you are on a private LAN where you trust all client connections, it is
# recommended to use https for all communications.
#
# SINCE 1.4.0
# RESTART REQUIRED
server.redirectToHttpsPort = false

# Specify the interface for Jetty to bind the standard 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.httpBindInterface = 192.168.137.1

# 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 = 192.168.137.1

# Alias of certificate to use for https/SSL serving.  If blank the first
# certificate found in the keystore will be used. 
#
# SINCE 1.2.0
# RESTART REQUIRED
server.certificateAlias = localhost
  1. 如果你电脑是32位机,修改gitblit-1.8.0data的installService.cmd为SET ARCH=x86,否则SET ARCH=amd64
  2. 安装win服务

  3. 确保为“自动”模式

  4. 设置防火墙规则以确保局域网中的其他机器可以访问服务器。







三.使用gitblit
  1. 浏览器输入 上面配置文件中的ip及端口,并修改账号和密码,开始的账号和密码都是“admin”
  2. 添加用户

  3. 然后将用户名和初始密码发送给团队成员登录


四. git与gitblit结合使用

参考链接:跳转

  1. 创建版本库,获得ssh连接。


  2. 在另一台电脑生成ssh公钥,比如我的是ubuntu,生成ssh方法如下

1). 设置git的user.name和user.email

git config --global user.name "xxx"
git config --global user.email "xx@xx.com"

2). 生成ssh key,简便做法就是直接按“回车”

ssh-keygen -t rsa

3).查看生成的ssh key,用来复制,复制ssh-rsa后部分即可

cat ~/.ssh/id_rsa.pub


3. 在网站上添加用户ssh,把上面得到的ssh添加进ssh key即可


4. 在ubuntu端克隆版本库,找到版本库url,在ubuntu的某目录下使用git clone “你的url”,进行克隆,这时候是空目录,往里面添加源码等文件,在使用git操作,进行代码提交即可。

git操作提示:

git add .   #添加目录下所有文件
git commit -m "修改说明"  #进行提交
git push    #推到仓库
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/321485.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号