在安装完毕gitlab后,登陆到页面后,咱们能够看到是没有任何项目,并且只有一个用户。在使用的时候,须要建立项目,并且会有对应的用户在项目中。下面练习这个操做html
- 新建用户组node
一、点击右上角的扳手按钮linux
二、在弹出的对话框中选择 new groupgit
三、Private:只有受权的用户才能够看到shell
Internal:只要是登陆上来的用户就能够看到windows
Public:任何组和项目均可以看到bash
- 组受权
app
一、能够看到建立完组之后,能够给组内添加成员。下面建立几个用户ssh
tips:一个组能够有多个项目ide
- 用户建立
一、点击右上角的扳手按钮
二、在弹出的对话框中选择 new user,下面建立了一个管理用户GYH,两个普通用户YH01和YH02
给用户添加到受权组中,并修改权限
如图,这样咱们就把GYH用户添加到Group1组中,并给予了master权限
- 建立项目
一、点击右上角的扳手按钮
二、在弹出的对话框中选择 new project
三、选择项目拥有者
四、建立完项目,要受权项目
当咱们建立完毕后,会有一个提示信息,以下,告知咱们须要配置了ssh才能使用ssh协议来push或者pull这个项目
You won't be able to pull or push project code via SSH until you add an SSH key to your profile
下面咱们就要对这个项目作权限处理,让它能够经过ssh来pull或者push动做
点击到上面的位置后,咱们须要登陆到须要受权链接到gitlab的设备上面。来复制密钥到gitlab上面。
下面以Linux设备ip为56.11为例,登陆到此设备上
经过ssh-keygen 一路回车来生成密钥,而后拷贝pul公钥到gitlab上去
点击Addkey按钮后,就添加成功!!
这里须要注意到是,gitlab上面登陆的帐号是YH01 是在这个帐号下添加到SSH key
若是不添加上面的ssh的话,你clone的时候会提示错误:错误提示以下图
给项目添加受权用户
添加完毕后,这个项目拥有了4个用户,其中两个是组里面继承过来的,另外两个是这个项目的用户,如图
当完成上面的设置后,使用YH01帐号登陆后,在登陆界面就能看到他所拥有的项目了
这个时候就能够从客户经过git glone来下载项目了
[root@linux-node1 ~]# git clone git@192.168.56.11:Group1/app1.git Cloning into 'app1'... The authenticity of host '192.168.56.11 (192.168.56.11)' can't be established. ECDSA key fingerprint is 28:3e:e9:97:c9:ff:33:16:41:23:0a:14:30:7c:5c:7f. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.56.11' (ECDSA) to the list of known hosts. warning: You appear to have cloned an empty repository. Checking connectivity... done. [root@linux-node1 ~]# ll total 277436 -rw-------. 1 root root 990 Dec 26 18:21 anaconda-ks.cfg drwxr-xr-x 3 root root 17 May 14 22:30 app1
这里因为app1项目是一个空的目录,下面咱们在这个目录上面新建一个文件readme
而后使用git pull来测试拉取
[root@linux-node1 app1]# git pull remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From 192.168.56.11:Group1/app1 * [new branch] master -> origin/master [root@linux-node1 app1]# ll total 4 -rw-r--r-- 1 root root 47 May 14 22:37 readme [root@linux-node1 app1]# cat readme readme建立一个床主主峰之 #这里能够看到,把master上面的readme文件拉取了下来了
二 windows客户端创建ssh免密钥登陆
一、安装工具
Git-2.7.2-32-bit_setup.1457942412.exe
二、在一个目录里面选择右键,选择“Git Bash Here”,会弹出一个shell窗口,这个窗口里面执行和Linux同样的ssh密钥生成命令。结果也会生成一个密钥
Tony@Tony-PC MINGW32 ~/.ssh $ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxfaZna8H+91hB4+GYPI2RcOzZhDleHx8sK8po5bq5wwk+tgRUSGQiLg8mA+HAxSIueylsKA0sfBCajP9k2hJ05vaOxr+UOqZ0yEytYqlQs0WIgX+VOAwkJDwGYgeZ7jZ3N0knem4GK8NRSWeoSwXseoZs9ddeFk3YVAaVykLDDngZ0YKsBkP7rjPn0JnFau8Me75cfIjuTnMVYPGY5YPJnN9MULjQvZB9mJ34E05a/4cAXZBSVKtumasBnIjTIbRFNVxcRjDohNdak1kZgdmOwMSyeCX+ADcV5vwgGZNxxWkRpOFV+W9vI/NqIpGktj7HD12XXtzxi8nnuozGe0SL Tony@Tony-PC Tony@Tony-PC MINGW32 ~/.ssh
三、把windows上面这个加到YH02用户上面
四、在gitlab上用YH02登陆上去,在profiles setting设置里面添加SSH Key添加上去,
五、从windows客户端上pull代码下来。
Tony@Tony-PC MINGW32 ~/.ssh $ git clone git@192.168.56.11:Group1/app1.git Cloning into 'app1'... The authenticity of host '192.168.56.11 (192.168.56.11)' can't be established. ECDSA key fingerprint is SHA256:l8F7OnGgtB8t1VEWnooak1oCP6UsZ3GJx1MPhssMv04. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.56.11' (ECDSA) to the list of known hosts. remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done. Checking connectivity... done. Tony@Tony-PC MINGW32 ~/.ssh $ ll total 6 drwxr-xr-x 1 Tony 197121 0 五月 15 14:36 app1/ -rw-r--r-- 1 Tony 197121 1675 五月 14 11:34 id_rsa -rw-r--r-- 1 Tony 197121 394 五月 14 11:34 id_rsa.pub -rw-r--r-- 1 Tony 197121 175 五月 15 14:36 known_hosts Tony@Tony-PC MINGW32 ~/.ssh $ cd app1/ Tony@Tony-PC MINGW32 ~/.ssh/app1 (master) $ ll total 1 -rw-r--r-- 1 Tony 197121 49 五月 15 14:36 readme Tony@Tony-PC MINGW32 ~/.ssh/app1 (master) $ cat readme readme建立一个床主主峰之 master brach Tony@Tony-PC MINGW32 ~/.ssh/app1 (master) $
Deploy Key
每一个项目都有个deploy key,项目部署公钥(Deploy Key)容许经过SSH协议以只读的方式访问项目,不须要输入密码,并且数据是使用你上传的公钥加密传输的。与HTTPS协议相比,SSH协议的数据传输效率要更高和稳定些,支持超大项目数据的传输。使用depoly key 后发现只能pull 不能push
这个通常是给jenkins使用的。
三 gitlab开发计划实施
假设如今已经有了一个开发计划,怎么作gitlab上实施这个开发计划那????
这里咱们使用管理帐号GYH来当项目经理,登陆到gitlab上面
在左面的菜单中选择Milestones里程碑,--》new milestones
新建新的issue来分配任务
依次建立4个issue
当咱们使用YH01或者YH02登陆到gitlab时候就能看到分配给本身的任务
开发者开始开发的流程
一、首先要建立一个新的分支
(1)能够经过命令建立分支
[root@linux-node1 app1]# git checkout -b shouye Switched to a new branch 'shouye' [root@linux-node1 app1]# git status On branch shouye nothing to commit, working directory clean
(2)在页面直接建立分支,而且会以当前issue的ID来命名分支
二、在分支上开发程序,并推送到分支上
[root@linux-node1 app1]# echo "shou ye wen jian" >index.html [root@linux-node1 app1]# git add . [root@linux-node1 app1]# git commit -m "shouye" [shouye 1f9cf77] shouye 1 file changed, 1 insertion(+) create mode 100644 index.html [root@linux-node1 app1]# git log commit 1f9cf77118cc8c8ec704bc1458db128fc25f39d2 Author: kesungang <605937099@qq.com> Date: Sun May 14 23:25:17 2017 +0800 shouye commit 34b7e533c414b0f27ab2d1e209e145bc5d0afd1b Author: YH01 <yh01@126.com> Date: Sun May 14 22:35:42 2017 +0800 first commit for master [root@linux-node1 app1]# git push origin shouye Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 284 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.56.11:Group1/app1.git * [new branch] shouye -> shouye
gitlab上在用户的项目里面能够查看到分支,而且点击分支,能够看到你的commit记录
三、开发完毕,分支请求合并到master分支上去
(1) 、能够从页面上的shouye分支,点击右边的Merge Request
(2)GYH项目经理登陆到gitlab上,能够从有上面的小铃铛,提示有任务,若是检查没有问题,接受合并请求
(3)测试正常合并的,能够关闭分支了
(4)分支更新(其余人就能够从master上面拉下最新内容了)
[root@linux-node1 app1]# git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'. [root@linux-node1 app1]# ll total 4 -rw-r--r-- 1 root root 47 May 14 22:37 readme [root@linux-node1 app1]# git pull remote: Counting objects: 1, done. remote: Total 1 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (1/1), done. From 192.168.56.11:Group1/app1 34b7e53..1f84445 master -> origin/master * [new branch] 1- -> origin/1- Updating 34b7e53..1f84445 Fast-forward index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 index.html [root@linux-node1 app1]# ll total 8 -rw-r--r-- 1 root root 17 May 15 00:13 index.html -rw-r--r-- 1 root root 47 May 14 22:37 readme
另一种commit 自动关闭分支任务
-rw-r--r-- 1 root root 47 May 14 22:37 readme [root@linux-node1 app1]# [root@linux-node1 app1]# git checkout -b news Switched to a new branch 'news' [root@linux-node1 app1]# git status On branch news nothing to commit, working directory clean [root@linux-node1 app1]# echo "xinwen" >news.html [root@linux-node1 app1]# ll total 12 -rw-r--r-- 1 root root 17 May 15 00:13 index.html -rw-r--r-- 1 root root 7 May 15 00:16 news.html -rw-r--r-- 1 root root 47 May 14 22:37 readme [root@linux-node1 app1]# git add . [root@linux-node1 app1]# git status On branch news Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: news.html [root@linux-node1 app1]# git commit -m "close #2"#使用#2格式来提交 [news 9def595] close #2 1 file changed, 1 insertion(+) create mode 100644 news.html [root@linux-node1 app1]# git status On branch news nothing to commit, working directory clean [root@linux-node1 app1]# git push origin news Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 303 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.56.11:Group1/app1.git * [new branch] news -> news