一:Gitlab
1,安裝gitlab
(1)安裝依賴
[root@Mankel ~] yum install -y curl policycoreutils-python openssh-server
(2) 下載軟體包
[root@Mankel ~] wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm --no-check-certificate
(3)安裝gitlab
[root@Mankel ~] rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm

(4)編輯組態檔
16行這個會有一個url的設定 ,我這里是修改過后的,將Ip替換成自己的ip即可
[root@Mankel ~] vim /etc/gitlab/gitlab.rb

[root@Mankel ~] gitlab-ctl reconfigure //重新配置gitlab的組態檔
[root@Mankel ~] gitlab-ctl start //啟動gitlab服務
ok: run: gitaly: (pid 17397) 0s
ok: run: gitlab-monitor: (pid 17412) 1s
ok: run: gitlab-workhorse: (pid 17442) 0s
ok: run: logrotate: (pid 17468) 1s
ok: run: nginx: (pid 17475) 0s
ok: run: node-exporter: (pid 17486) 0s
ok: run: postgres-exporter: (pid 17492) 1s
ok: run: postgresql: (pid 17501) 0s
ok: run: prometheus: (pid 17573) 1s
ok: run: redis: (pid 17585) 0s
ok: run: redis-exporter: (pid 17590) 1s
ok: run: sidekiq: (pid 17610) 0s
ok: run: unicorn: (pid 17619) 1s
(5)打開瀏覽器輸入組態檔中對應的地址:

(6)地址:http://192.168.180.132/

(7)注意事項:
訪問成功了,如果失敗了首先多次嘗試重繪
還是失敗的話檢查:
1.gitlab頁面的出現的問題; 檢測埠號80和8080是否被占用;
2.訪問主頁502的時候,看一下埠號8080是否被占用
一般第一次會讓你修改密碼 ,改成對應的密碼后填寫
賬號:root
密碼:自己設定的
創建一個專案,箭頭指向的是專案的url地址

(8)配置smtp郵箱步驟
###修改組態檔
[root@Mankel ~] vim /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_email_from'] = 'xxx@163.com' //說明郵箱從哪里發,設定自己的郵箱地址
#ctrl+v 進入可視塊 +x
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com" //在線郵件服務器地址
gitlab_rails['smtp_port'] = 25 //埠號,開啟本地發郵件的埠
gitlab_rails['smtp_user_name'] = "xxx@163.com" //郵箱地址
gitlab_rails['smtp_password'] = "dhasiuhfiq2414" //郵箱授權碼,呼叫郵箱(自填)
###郵箱授權碼的獲取
設定
POP3/SMTP/IMAP
客戶端授權密碼,在里面就可以設定授權碼
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login" //在登錄時,查看是否有授權碼
gitlab_rails['smtp_enable_starttls_auto'] = true //加密方式
gitlab_rails['smtp_tls'] = false //加密方式
user['git_user_email'] = "xxx@163.com"
###修改完成
重新編譯組態檔
[root@Mankel ~] gitlab-ctl reconfigure
重啟gitlab服務
[root@Mankel ~] gitlab-ctl restart
進入控制臺
[root@Mankel ~] gitlab-rails console
Loading production environment (Rails 5.0.7.1)
irb(main):001:0> Notify.test_email('xxxx@163.com','yangxiaofeiNB','hello,world!').deliver_now //發送郵件,deliver_now代表立刻發送
(格式:收件人的郵箱地址,郵件標題,郵件內容)
irb(main):003:0> exit //退出控制臺
(9)配置gitlab資料存放地址
更改倉庫存盤位置
默認時GitLab的倉庫存盤位置在“/var/opt/gitlab/git-data/repositories”,在實際生產環境中顯然我們不會存盤在這個位置,一般都會劃分一個獨立的磁區來存盤倉庫的資料,我這里規劃把資料存放在“/data/git-data”目錄下,
[root@Mankel ~] mkdir -pv /data/git-data
[root@Mankel ~] chown -R git.git /data/git-data #修改創建目錄的屬主和屬組為git用戶
[root@Mankel ~] cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
[root@Mankel ~] vim /etc/gitlab/gitlab.rb
#啟用git_data_dirs引數,并修改如下:
git_data_dirs 路徑 “/data/git-data”

重新編譯組態檔
[root@Mankel ~] gitlab-ctl reconfigure
重啟gitlab服務
[root@Mankel ~] gitlab-ctl restart
(10)gitlab啟停命令
啟動gitlab服務
gitlab-ctl start
gitlab服務停止
gitlab-ctl stop
重啟gitlab服務
gitlab-ctl restart
二.git
windowns
1.這里直接使用軟體管家安裝了git

2.創建了一個空目錄存放本地代碼,右擊顯示有git,說明安裝成功

3.點擊Git GUI Here,查看密鑰

4.點擊箭頭指向,創建密鑰,創建完成后點擊Copy To Clipboard復制

5.點擊gitlab上的用戶下的設定

6.找到ssh keys,將key粘貼進去,add創建

7.這時我們就可以在本地進行git操作了

8.點擊Git Bash Here進入命令列

9.復制專案地址

10.拉取專案內容,
git clone 專案地址

11.到專案目錄下創建一個test檔案

12.git add . 提交 ,發現需要設定用戶的郵箱地址和用戶

13.git config --global user.email “xxx@163.com” #自己的郵箱
git config --global user.name “xxx” #自己的名字
設定完成后繼續提交

14.提交完成,發現gitlab專案上成功發現檔案test.txt

到這里就完成了安裝以及簡單使用
git 常用命令:
拉取為本地專案
git clone
創建本地分支
git branch branchName
查看分支
列出所有本地分支
git branch
#列出所有遠程分支
git branch -r
#列出所有本地分支和遠程分支
git branch -a
提交本地分支到遠程分支
git push origin branchName:branchName
切換分支
git checkout branchName
提交代碼
git add .
git commit -m “test”;
git push
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/349767.html
標籤:其他
上一篇:使用navicat連接虛擬機里的openGauss資料庫
下一篇:Python 虛擬機安裝步驟
