創建用戶james
創建群組microservice
在群組microservice里面創建項目portal:
設置項目:
添加readme:
群組邀請成員:
把用戶pj,添加並賦予developer角色:
重新用pj用戶用戶名james來登陸,顯示群組和項目已經看到:
用戶權限:
用ssh方式的話,配置文件需要設置docker暴露的端口2222:
[root@k8s-2 nohttp]# docker exec -it gitlab bash
root@gitlab:/# cat /etc/gitlab/gitlab.rb |grep ssh_port
gitlab_rails['gitlab_shell_ssh_port'] = 2222
重啟gitlab后,上圖的克隆地址會改變:
ssh://git@gitlab.ctnrs.com:2222/microservice/portal.git
SSH使用:
1、修改配置文件指定gitlab對外暴露SSH端口
# docker exec -it gitlab bash
# vi /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_shell_ssh_port'] = 2222
# docker restart gitlab
2、ssh-keygen生成密鑰對
3、點擊用戶頭像->設置->SSH密鑰->添加公鑰(id_rsa.pub)
4、測試:gitclone免認證git clone ssh://git@gitlab.ctnrs.com:2222/microservice/portal.git
HTTP使用:
http克隆到本地,不用密鑰,輸入web登錄的用戶和密碼即可:
git clone http://gitlab.ctnrs.com/microservice/portal.git
新建分支、在新分支新建文件、提交到遠程倉庫:
新建分支:
[root@k8s-2 touch]# git branch
* master
[root@k8s-2 touch]# ls
index.html README.md
[root@k8s-2 touch]# git checkout -b new
Switched to a new branch 'new'
[root@k8s-2 touch]# git branch
master
* new
[root@k8s-2 touch]# ls
index.html README.md
在新分支新建文件:
[root@k8s-2 touch]# vim aaa
[root@k8s-2 touch]# ls
aaa index.html README.md
新建文件后,master和新分支都同時出現了新建的文件:
[root@k8s-2 touch]# git checkout master
Switched to branch 'master'
[root@k8s-2 touch]# ls
aaa index.html README.md
提交到遠程倉庫:
[root@k8s-2 touch]# git checkout new
Switched to branch 'new'
[root@k8s-2 touch]# git add .
[root@k8s-2 touch]# git commit -m 'new'
[root@k8s-2 touch]# git push origin new
提交后,新分支的新文件還在:
[root@k8s-2 touch]# ls
aaa index.html README.md
[root@k8s-2 touch]# git branch
master
* new
提交后,master分支的新文件沒有了:
[root@k8s-2 touch]# git checkout master
Switched to branch 'master'
[root@k8s-2 touch]# ls
index.html README.md