• 为什么写博客,是因为遇到的坑,不希望别人在踩一遍!
  • 选择了,剩下的就是坚持和努力-------致自己!
  • 当能力达不到梦想时,更需要学习,努力,拼搏

Gitlab五 管理、使用

GitLab 雪豹 7年前 (2017-08-24) 964次浏览 0个评论


9.1.2 右击gitlab菜单选择 组 Groups

9.1.3 点击项目 进入

进入项目后选择member查看成员目前为 Administrator (点击进入)

9.1.4 进入管理员添加 ssh key
选择 setting(设置)看好位置是右上角的Administrator 的设置

9.1.5 在项目中选择 SSH Keys 添加
在Key中添加所要连接gitlab 项目 主机的公钥(注意:用户我这里是www)

ssh key 查看
[www@node1 .ssh]$ ls -l
总用量 16
-rw------- 1 www www 2350 7月  17 2017 authorized_keys
-rwx------ 1 www www 1675 11月 14 14:58 id_rsa    #私钥
-rwx------ 1 www www  391 11月 14 14:58 id_rsa.pub #公钥
-rw-r--r-- 1 www www 1198 7月   2 2017 known_hosts
 [www@node1 .ssh]$ cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1rLXksP+dqPJum8Vuukh/T81Bu9LGgwPlnQ5jBprlhpyt4/dGEuosQGhSpBlI6Kasg6BUuRPCq/8MRkyI4/QyE+1pWhwurLhn5dPG1EH8uynmqiIHTrrklkFOimhOu4RAaOQzesSc0f
/6KL+S5ZTAW6cW1VFmplTh5iyeGWthgfuliyehHTwLJRoXYMxo4jEF0BtAUUPM1PU6zo9YhbQ/ayuRnnMbN7ZXEzmx6TMSHJ7qRxdT2TxezdGmUyn5/M1nToxjtKbV/QV1cphU7zM3uzjXQHFU/8naOx4H7+V8Ir/TWEo6+DukNOkD0qEq8L+FIeuK1oLBhot9wRjBTTIgw== www@node1

9.1.6 查看ssh key
已经添加的用户,可以在下面查看。

9.2 web主机克隆gitlab 项目、上次文件
注意:每台主机解析 查看hosts 或本地有dns 服务器

[root@jenkins web-demo]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.55 gitlab.example.com
172.16.1.67 node1
172.16.1.79 node2

备注信息:
备注下 gitlab 服务器 172.16.1.55
客户端:172.16.1.67 node1 172.16.1.79 node2
9.2.1 test 为我测试目录

[www@node2 webroot]$ cd test/
[www@node2 test]$ ls
9.2.2 在进入gitlab 中 自己想克隆的项目中
复制git 地址(在此强调一定要做本地解析哦,不然git clone报错)
<h3>9.2.3 git clone 无法解析错误如下:</h3>
[www@node2 test]$ git clone git@gitlab.example.com:web/web-demo.git
Initialized empty Git repository in /deploy/test/web-demo/.git/
The authenticity of host 'gitlab.example.com (172.16.1.55)' can't be established.
RSA key fingerprint is d3:1f:d7:60:56:6c:4e:f0:90:5a:bf:83:ad:e7:93:77.

9.2.4 正确的:

[www@node2 test]$ git clone git@gitlab.example.com:web/web-demo.git
Initialized empty Git repository in /webroot/test/web-demo/.git/
The authenticity of host 'gitlab.example.com (172.16.1.55)' can't be established.
RSA key fingerprint is d3:1f:d7:60:56:6c:4e:f0:90:5a:bf:83:ad:e7:93:77.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.example.com,172.16.1.55' (RSA) to the list of known hosts.
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 9 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (9/9), 684 bytes, done.
Resolving deltas: 100% (1/1), done.
查看文件已克隆
[www@node2 test]$ ls
web-demo
进入克隆项目
[www@node2 test]$ cd web-demo/
[www@node2 web-demo]$ ls #查看
index.html  LICENSE  README.md

9.2.5 vim编写测试文件

[www@node2 web-demo]$ vim test.txt

9.2.6 git add 添加 test.txt
[www@node2 web-demo]$ git add test.txt
9.2.7 git commit –m 备注

[www@node2 web-demo]$ git commit -m "add test.txt"
[master c7ab13a] add test.txt
 Committer: www <www@node2.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

备注:首次提交需要备注 姓名和邮箱 Git通过检测用户名和邮箱来跟踪进行commit的用户
[www@node2 web-demo]$ git config –global user.name “xuebao”
[www@node2 web-demo]$ git config –global user.email 765289948@qq.com

9.2.8 在此 git commit

[www@node2 web-demo]$ git commit -m "add test.txt"
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)

9.2.9 git push 向gitlab 项目中推

[www@node2 web-demo]$ git push
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 266 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@gitlab.example.com:web/web-demo.git
   f795da0..c7ab13a  master -> master

拉取gitlab 项目

[www@node1 web-demo]$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From gitlab.example.com:web/web-demo
   c7ab13a..df11e1b  master     -> origin/master
Updating c7ab13a..df11e1b
Fast-forward
 test2.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test2.txt
[www@node1 web-demo]$ ls
index.html  LICENSE  README.md  test2.txt  test.txt
取
[www@node1 shell]$ cd /webroot/
[www@node1 webroot]$ ls
test  web-demo
[www@node1 webroot]$ cd test/
[www@node1 test]$ ls
web-demo
[www@node1 test]$ git show
fatal: bad default revision 'HEAD'
[www@node1 test]$ cd web-demo/
[www@node1 web-demo]$ ls
index.html  LICENSE  README.md  test2.txt  test.txt

git show 查看

[www@node1 web-demo]$ git show
commit df11e1b0d7842d84bb05f7d41ad0b5befdb25c79
Author: xuebao <765289948@qq.com>
Date:   Sun Jul 2 22:56:40 2017 +0800

    add test2.txt

diff --git a/test2.txt b/test2.txt
new file mode 100644
index 0000000..9352d8c
--- /dev/null
+++ b/test2.txt
@@ -0,0 +1 @@
+ii
9.2.10 git show 
[www@node1 web-demo]$ git show |grep commit
commit df11e1b0d7842d84bb05f7d41ad0b5befdb25c79
[www@node1 web-demo]$ git show |grep commit|cut -d ' ' -f2
df11e1b0d7842d84bb05f7d41ad0b5befdb25c79
[www@node1 web-demo]$ git show |grep commit|cut -d ' ' -f2
取值
[www@node1 web-demo]$ API_VERL=$(git show|grep commit|cut -d ' ' -f2)
[www@node1 web-demo]$ echo ${API_VERL:0:6}
df11e1

第10章 gitlab 修改 ssh 连接地址名称:

[root@jenkins etc]# rpm -qa|grep gitlab-ce
gitlab-ce-8.17.5-ce.0.el6.x86_64
[root@jenkins etc]# find / -type f -name "gitlab.rb"

 [root@jenkins etc]# vim /etc/gitlab/gitlab.rb

	修改后external_url 'http://172.16.1.55'

重新修改配置才生效(一般安装完需修改的地方)

[root@jenkins etc]# gitlab-ctl reconfigure


有需要可以联系微信xuebao19930721和加入微信群
喜欢 (0)

发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址