Linux centos7上gitlab伺服器的搭建,本地配置和使用
阿新 • • 發佈:2018-12-09
1 gitlab的搭建
1. 安裝一堆包,和 啟動相關服務
yum install -y curl policycoreutils-python
yum install -y openssh-server openssh-clients
systemctl enable sshd
systemctl start sshd
yum install postfix
systemctl enable postfix
systemctl start postfix //如果失敗,
//請將/etc/hosts檔案中的ipv6的設定刪掉
firewall-cmd --permanent --add-service =http
systemctl reload firewalld
2. 安裝gitlab
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
//或者選擇其他更新的版本。
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
3.配置gitlab
編輯檔案:/etc/gitlab/gitlab.rb ,修改
external_url 'http://192.168.1.1:8080'
//url的內容和埠,可自行定義,切記不要衝突
gitlab-ctl reconfigure
4.登入 預設管理員賬戶是:root. 此時訪問設定的url,會提示你設定新的密碼,進行設定登入即可。
2 本地的配置
1. 新增和配置SSH公鑰:
ssh-keygen -t rsa -C "[email protected]"
出現的讓輸入內容,一直按照預設的就可以了,直接enter。產生rsa。
2. 檢視:/root/.ssh/id_rsa.pub 檔案內容。複製
3. 登入gitlab,點選setting-->ssh keys. 貼上複製的內容。
OK,現在可以通過git clone url 來進行免密進行訪問和同步了。
3 常用使用命令
1. 提交程式碼,增加到版本庫
git commit -m '備註資訊'
2.增加到暫存區
git add index.html
git add -A
3 比較暫存區與程式碼庫
git diff
4 取消增加暫存區的內容
git reset HEAD filename
5 刪除暫存區的檔案
git rm index.html --cached
6 分支管理
git branch dev //建立
git checkout dev //切換
git branch -d dev //刪除
git commit -a -m 'dev1' //分支上提交新的版本
git merge dev //合併