gitlab

gitlab安裝

GitLab 是一個用於倉庫管理系統的開源項目。使用Git作爲代碼管理工具,並在此基礎上搭建起來的web服務。可
通過Web界面進行訪問公開的或者私人項目。它擁有與Github類似的功能,能夠瀏覽源代碼,管理缺陷和註釋。可
以管理團隊對倉庫的訪問,它非常易於瀏覽提交過的版本並提供一個文件歷史庫。團隊成員可以利用內置的簡單聊
天程序(Wall)進行交流。它還提供一個代碼片段收集功能可以輕鬆實現代碼複用。
常用的網站:
官網:https://about.gitlab.com/
國內鏡像:https://mirrors.tuna.tsinghua.edu.cn/gitlab‐ce/yum/
安裝環境:
1、 CentOS 6或者7
2、 2G內存(實驗)生產(至少4G)
3、 安裝包:gitlab‐ce‐10.2.2‐ce
4、 關閉selinux
https://about.gitlab.com/installation/#centos‐7 # git官網
yum install ‐y curl policycoreutils‐python openssh‐server # 安裝依賴
cd /soft
rz ‐bye gitlab‐ce‐10.2.2‐ce.0.el7.x86_64.rpm # 上傳gitlab安裝包
[root@gitlab soft]# yum localinstall gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm  下載方式可通過
國內清華源gitlab‐ce社區版本下載
[root@gitlab soft]# ls
gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
[root@gitlab soft]# gitlab-ctl reconfigure

vim /etc/gitlab/gitlab.rb # gitlab 配置文件
更改url地址爲本機IP地址 external_url 'http://10.0.0.85'

gitlab‐ctl reconfigure # 更改配置文件後需重新配置

/opt/gitlab/ # gitlab的程序安裝目錄
/var/opt/gitlab # gitlab目錄數據目錄
/var/opt/gitlab/git‐dfata # 存放倉庫數據
gitlab‐ctl status # 查看目前gitlab所有服務運維狀態
gitlab‐ctl stop # 停止gitlab服務
gitlab‐ctl stop nginx # 單獨停止某個服務
gitlab‐ctl tail # 查看所有服務的日誌
tail -f /var/log/gitlab
通過瀏覽器輸入IP地址進行訪問gitlab

在這裏插入圖片描述
在這裏插入圖片描述

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

[root@gitlab soft]# ssh-keygen -t rsa
[root@gitlab soft]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCdELo9cywu6MxM0JYQ/vPUyga3CfKgX+ll+UVCqLtyYs8939dfHZfUtTf4uzx3KxDvOHrvXOkydW0B6e0fqa1RqIgIaUJ9FGJqMPkzEgErSw8msnAvhR0P24ISPozshLsd+LQ8kz2mBAWzuLUm/r/QWhUxys1AiOo2/AWV8tECvjRSpdlXpOkEYBBCeNDnG8W+ixvxCxiWtp1gnjbKgRTr1e34n7Ea9j2z4Uh9R4iVsEY+uolk8BehAGS9lA6knvmtvaaIdom2chXXzRZty0KHp0blWKcbVxsd+OhXDGF72dRL6800u3o9rZcR6WKuWZLTvCt+FM8OrQF3ISYXf5CB root@gitlab


在這裏插入圖片描述
在這裏插入圖片描述

 # 刪除關聯的遠程倉庫
git remote remove <遠程倉庫name>
# 添加新的遠程倉庫關聯
git remote add <遠程倉庫name> <url(ssh或者http>
# 查看關聯的遠程倉庫的名稱
git remote
# 查看關聯的遠程倉庫的詳細信息
git remote -v
[root@gitlab ~]# git config --global user.name "Administrator"
[root@gitlab ~]# git config --global user.email "[email protected]"
[root@gitlab ~]# mkdir git_data
[root@gitlab ~]# cd git_data
[root@gitlab git_data]# git init
[root@gitlab git_data]# ls
2000.png  21.js  icon.png  img  index.html  sound1.mp3
[root@gitlab git_data]# git add .
[root@gitlab git_data]# git commit -m "x-plan Numb1"
[root@gitlab git_data]# git remote add origin [email protected]:ops/git_data.git
[root@gitlab git_data]# git push -u origin master

   

創建不同用戶

在這裏插入圖片描述
在這裏插入圖片描述在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

將不同用戶添加到相應組中

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

[root@jenkins ~]# git clone [email protected]:ops/git_data.git
[root@jenkins ~]# ls
anaconda-ks.cfg  git_data
[root@jenkins ~]# cd git_data/
[root@jenkins git_data]# ls
2000.png  21.js  icon.png  img  index.html  sound1.mp3
[root@jenkins git_data]# git remote
origin
#從遠程倉庫拉取下來的代碼後,自動設置了遠程倉庫

開發修改了代碼,如何上傳

[root@jenkins git_data]# vim index.html #修改代碼
[root@jenkins git_data]# git config --global user.email "[email protected]"
[root@jenkins git_data]# git config --global user.name "dev"
[root@jenkins git_data]# git commit -m "modify title"
[root@jenkins git_data]# git add .
[root@jenkins git_data]# git commit -m "modify title"
#也可以直接git commit -am "modify title"  #如何某個文件已經被倉庫管理過,可直接使用-am ,而不需要git add .
[root@jenkins git_data]# git push -u origin master


在這裏插入圖片描述

設置分支保護(不允許開發直接上傳代碼到master分支上)

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

[root@jenkins git_data]# git push -u origin dev
#開發把代碼傳到dev分支上.

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

發佈了108 篇原創文章 · 獲贊 1 · 訪問量 4534
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章