gitlab创建用户、群组、项目、分支、上传


 

 

创建用户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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM