Java 庫用來管理、查看和處理 Git 的資料庫工具,相當於 Git 的 Java 管理工具。通俗點來說就是一個相當於 SVN 的工具,用於多個人共同開發同一個項目,共用資源的目的。
1 軟件安裝
- 搭建環境:windows 系統、Java SE 1.8 (選擇64位的)
直接按照指示安裝即可,接着需要配置 Java 的環境。
右擊我的電腦
,點擊屬性
,選擇高級系統設置
:
1.1 java 環境配置
變量名 | 變量值 |
---|---|
JAVA_HOME | C:\Program Files\Java // 要根據自己的實際路徑配置 |
Path | %JAVA_HOME%\jdk-1.8\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 地址
GitBlit 使用
啓動 gitblit 界面,在左上角有個登錄框,初始值用戶名和密碼均爲 admin
,然後便可以添加用戶和團隊並設置其權限:
添加 rsa 密鑰
選擇用戶中心
:
在 SSH Key 欄可以看到一個空白的輸入框,其內容可以通過如下方式獲取:
- 再次添加一個終端並在終端輸入:
$ ssh-keygen -t rsa # 生成密鑰
$ cat ~/id_rsa.pub # 查看密鑰
便可以獲取本地使用的 rsa 密鑰,複製到 SSH Key 框中,點擊 添加
按鈕即可。