Gitblit版本服務器環境部署記錄


  

Gitblit介紹
Gitblit 是一個純 Java 庫用來管理、查看和處理 Git 資料庫.相當於 Git 的 Java 管理工具,支持linux系統。
Git是分布式版本控制系統,它強調速度、數據一致性,並且支持分布式、非線性工作流。它最初由Linus Torvalds在2005年為Linux內核設計和開發,使用GPLv2證書,
並從此成為軟件開發中使用最廣泛的版本控制系統。
Gitblit是完全開源的軟件,它基於純粹的Java堆棧,被設計以在Git倉庫速度和效率方面勝任從小型到極大型的項目。它很容易學習和上手,並有着閃電般的性能。它在很
多方面遠勝Subversion、CVS、Perforce和ClearCase等SCM(版本控制)工具,比如,如快速本地分支、易於暫存、多工作流等。

下面介紹Gitblit的安裝(Ubuntu/Fedora/CentOS)

Git是一款注重速度、數據完整性、分布式支持和非線性工作流的分布式版本控制工具。Git最初由Linus Torvalds在2005年為Linux內核開發而設計,如今已經成為被廣
泛接受的版本控制系統。和其他大多數分布式版本控制系統比起來,不像大多數客戶端-服務端的系統,每個Git工作目錄是一個完整的倉庫,帶有完整的歷史記錄和完整的版本
跟蹤能力,不需要依賴網絡或者中心服務器。像Linux內核一樣,Git也是在GPLv2許可證下分發的自由軟件。

[root@gitblit-server ~]# yum -y install java-1.7.0-openjdk*         //要提前安裝java環境
[root@gitblit-server ~]# mkdir -p /opt/gitblit
[root@gitblit-server ~]# cd /opt/gitblit
[root@gitblit-server gitblit]# wget http://dl.bintray.com/gitblit/releases/gitblit-1.6.2.tar.gz
[root@gitblit-server gitblit]# tar -zvxf gitblit-1.6.2.tar.gz 
[root@gitblit-server gitblit]# ls
add-indexed-branch.sh  ext                   gitblit-stop.sh            java-proxy-config.sh  reindex-tickets.sh
authority.sh           gitblit-1.6.2.tar.gz  install-service-centos.sh  LICENSE               service-centos.sh
data                   gitblit.jar           install-service-fedora.sh  migrate-tickets.sh    service-ubuntu.sh
docs                   gitblit.sh            install-service-ubuntu.sh  NOTICE

默認配置文件在data/gitblit.properties,可以根據需要自己修改。

啟動gitlit服務:

第一種方式:通過service命令:
[root@gitblit-server gitblit]# cp service-centos.sh /etc/init.d/gitblit
[root@gitblit-server gitblit]# chkconfig --add gitblit
[root@gitblit-server gitblit]# service gitblit start
Starting gitblit server
.
[root@gitblit-server gitblit]# ps -ef|grep gitblit
root      7421     1 99 11:19 pts/0    00:00:13 java -server -Xmx1024M -Djava.awt.headless=true -jar /opt/gitblit/gitblit.jar --httpsPort 8443 --httpPort 0 --baseFolder /opt/gitblit/data --dailyLogFile
root      7447  7217  0 11:19 pts/0    00:00:00 grep gitblit

第二種方式,手動啟動:
[root@gitblit-server gitblit]# java -jar gitblit.jar --baseFolder data
2017-05-31 11:51:17 [INFO ] *****************************************************************
2017-05-31 11:51:17 [INFO ]             _____  _  _    _      _  _  _
2017-05-31 11:51:17 [INFO ]            |  __ \(_)| |  | |    | |(_)| |
2017-05-31 11:51:17 [INFO ]            | |  \/ _ | |_ | |__  | | _ | |_
2017-05-31 11:51:17 [INFO ]            | | __ | || __|| '_ \ | || || __|
2017-05-31 11:51:17 [INFO ]            | |_\ \| || |_ | |_) || || || |_
2017-05-31 11:51:17 [INFO ]             \____/|_| \__||_.__/ |_||_| \__|
2017-05-31 11:51:17 [INFO ]                          Gitblit v1.6.2
2017-05-31 11:51:17 [INFO ] 
2017-05-31 11:51:17 [INFO ] *****************************************************************
2017-05-31 11:51:17 [INFO ] Running on Linux (2.6.32-642.el6.x86_64)
2017-05-31 11:51:17 [INFO ] Logging initialized @1233ms
2017-05-31 11:51:17 [INFO ] Using JCE Unlimited Strength Jurisdiction Policy files
2017-05-31 11:51:17 [INFO ] Setting up HTTPS transport on port 8443
2017-05-31 11:51:17 [INFO ]    certificate alias = localhost
2017-05-31 11:51:17 [INFO ]    keyStorePath   = /opt/gitblit/data/serverKeyStore.jks
2017-05-31 11:51:17 [INFO ]    trustStorePath = /opt/gitblit/data/serverTrustStore.jks
2017-05-31 11:51:17 [INFO ]    crlPath        = /opt/gitblit/data/certs/caRevocationList.crl
........

確保gitblit的8443端口已打開
[root@gitblit-server gitblit]# lsof -i:8443
COMMAND  PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
java    7421 root   94u  IPv6 1224421      0t0  TCP *:pcsync-https (LISTEN)

打開瀏覽器,依據你的配置進入https://localhost:8443。 輸入默認的管理員授權:admin / admin 並點擊Login 按鈕

添加用戶操作

 

添加倉庫操作

這樣就在組huanqiu下創建了hqpc的代碼倉庫。還可以在huanqiu組下創建其它的倉庫

可以是用上面創建的wangshibo用戶登陸,然后將客戶機的ssh公鑰添加到gitblit的wangshibo用戶下,這樣就能使用ssh方式進行操作了。

添加客戶機公鑰,可以設置操作權限(讀寫權限)

然后就可以在客戶機上進行代碼操作了

[root@Agent-node1 ~]# cd /opt
[root@Agent-node1 opt]# git clone ssh://wangshibo@182.48.115.233:29418/huanqiu/hqpc.git
Initialized empty Git repository in /opt/hqpc/.git/
warning: remote HEAD refers to nonexistent ref, unable to checkout.

[root@Agent-node1 opt]# ls
hqpc
[root@Agent-node1 opt]# cd hqpc/
[root@Agent-node1 hqpc]# echo "123123" > test.txt
[root@Agent-node1 hqpc]# git add test.txt
[root@Agent-node1 hqpc]# git commit -m "added by wangshibo"
[master (root-commit) fd709a4] added by wangshibo
 Committer: root <root@Agent-node1.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com              //可以在操作下執行這兩行,進行全局設置(不操作也行)

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

 [root@Agent-node1 hqpc]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 222 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Updating references: 100% (1/1)
To ssh://wangshibo@182.48.115.233:29418/huanqiu/hqpc.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

然后登陸到gitblit頁面,查看test.txt文件是否已經成功推到了hqpc倉庫里了

-------------------------------------------------------------------------- 

還可以設置用戶的訪問權限

中英文顯示,可以在"用戶中心"的"偏好設置"里選擇中文或是英文顯示

可以在"我的公告板"里查看最近的操作記錄情況


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM