技术流ken

运维拯救世界

Gitlab仓库搭建及在linux/windows中免密使用gitlab(二)–技术流ken

Gitlab简介

 

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用。

管理的命令
gitlab-ctl stop
gitlab-ctl start
gitlab-ctl restart

Gitlab的安装

 

第一步:上传安装包

[root@ken ~]# rz

[root@ken ~]# ls | grep git

   gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm

 

第二步:使用yum安装

[root@ken ~]# yum localinstall gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm -y

 

第三步:修改配置文件

在文件11行左右把主机名修改为你的IP地址

复制代码
[root@ken ~]# vim /etc/gitlab/gitlab.rb 
... ## Url on which GitLab will be reachable. 9 ## For more details on configuring external_url see: 10 ## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/configuration.md#c onfiguring-the-external-url-for-gitlab 11 external_url 'http://10.220.5.137' 12 13 14 ## Note: configuration settings below are optional. 15 ## Uncomment and change the value. 16 ############################ 17 # gitlab.yml configuration # 18 ############################
...
复制代码

 

第四步:使配置生效

需要一定的时间

复制代码
[root@ken ~]# gitlab-ctl reconfigure
...

Running handlers:
Running handlers complete
Chef Client finished, 224/314 resources updated in 02 minutes 55 seconds
gitlab Reconfigured!

复制代码

 

第五步:浏览器查看

直接输入服务器IP即可访问

 

在这里输入新的密码,密码长度8位,点击change your password

点击之后跳转到如下的界面

把Admin换成root,密码就是刚才设置的密码,点击sign in

 

跳转到如下的界面即成功

 

 

 

Gitlab的使用-创建项目

 

第一步:创建用户

第一步: 点击左上角的扳手符号

 

第二步:点击NEW USER

 

第三步:填写用户信息

 

第二步:创建项目组

第一步:点击NEW GROUP

 

第二步:填写项目组信息

 

第三步:创建项目

第一步:点击NEW PROJECT

 

第二步:填写项目信息

project owner填写项目组的组名

 

Gitlab在linux中的使用

用到的命令

1.git add

2. git commit

3. git push origin 字分支名字

第一步:创建工作目录

[root@ken ~]# mkdir lll
[root@ken lll]# cd lll

 

第二步:从web仓库中下载项目

使用git clone

复制代码
[root@ken lll]# git clone http://10.220.5.137/webs/webss.git
Cloning into 'webss'...
Username for 'http://10.220.5.137': root
Password for 'http://root@10.220.5.137': 
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
[root@ken lll]# ls
nginx_pro  webss
复制代码

 

第三步:创建新的分支

进入到工作目录之下,即包含.git的目录

复制代码
[root@ken lll]# cd webss/
[root@ken webss]# ls -a
.  ..  .git  hy  README
[root@ken webss]# git branch
* master
[root@ken webss]# git branch dev
[root@ken webss]# git checkout dev
复制代码

 

第四步:创建测试文件并上传

复制代码
[root@ken webss]# echo "test88888">test.file
[root@ken webss]# git add .
[root@ken webss]# git commit -m "test.file"
[master 4654ba0] test.file
 1 file changed, 1 insertion(+)
 create mode 100644 test.file
[root@ken webss]# git push origin dev #当前子分支的名字
复制代码

 

第五步:在网页查看gitlab

可以看到多个一个我们刚才在子分支创建的一个测试文件

 

Gitlab在linux中的使用之秘钥登录

在上面我们每次登录gitlab都要输入名字和面是不是很麻烦?

没关系,现在我们用秘钥来解决这个问题

第一步:查看web端gitlab的秘钥地址

第二步:在本机生成秘钥文件并查看公钥

复制代码
[root@ken webss]# ssh-keygen
[root@ken webss]# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGFGu/W0rx9XiTM6aehm71Vz30TzsLUb5/mCnLjUeJ1sZMS5MONeDR+AoYbXsbXE4vmZfMunEwqIKnduMctieWd/F0//+4FtOWmp0XAkJgatml4bqjvJ1ARxVyDOrXxQKsElC7MmRqw6ghONcoToytZbnXP9J9if6HHiU4sYVxJUKSAFngmk1Ta8DBwC7cvrVS7TFreCq2q0WIQPak2YHt3PUGZkt/LFrWqCJcWYI5dE3/++sWpalLFJQev0jRL6DQDGfxQmxS5AmeMZvFa3d0FUJLVpzzMjNh+2hIT8IJoaA0BSmowGUtFGc++HBqMvXPohIQTBL3aD4uf6aK4ct9 root@ken
复制代码

 

第三步:复制秘钥信息填写进web服务端

 

第四步:点击提交之后再次下载仓库信息

注意这里git clone之后写的是ssh的信息,不是http的连接信息了

回车之后可以看到没有输入任何东西就直接下载完成

复制代码
[root@ken k]# git clone git@10.220.5.137:webg1/webss.git
Cloning into 'webss'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.

[root@ken k]# ls
 webss

复制代码

 

Gitlab在window中的使用

第一步:准备文件

你需要首先在网上下载下面的这个客户端工具

 

第二步:安装

 

第三步:创建一个文件夹作为工作目录并进入目录之后

右击鼠标有两个选项,一个是bash一个是图形化,我选择bash,会出现如下的界面

 

第四步:生成秘钥信息,进行免密登录

在这个界面输入ssh-keygen一直点回车生成秘钥信息

 

第五步:把公钥信息输入到web服务端

可以从上面的信息中看到秘钥信息保存在哪了,现在我们去c盘找

复制这个公钥里面的信息

 

第六步:本地下载仓库

使用git clone 加上你的项目ssh信息

第七步:本地查看

发现已经有了仓库信息了,现在你就可以开始写程序了

 

 

 

 

第八步:测试

进入到包含.git的目录并在此右击打开bash,执行创建分支操作,并建立test.txt测试文件

 

第九步:上传文件

和linux中一样执行如下命令

 

第十步:在web中查看

可以看到我们刚才在window中创建的文件也已经被上传上来了

11 thoughts on “Gitlab仓库搭建及在linux/windows中免密使用gitlab(二)–技术流ken

  1. gitlab-ctl stop
    ok: down: gitlab-workhorse: 1s, normally up
    ok: down: logrotate: 0s, normally up
    ok: down: nginx: 1s, normally up
    ok: down: postgresql: 0s, normally up
    ok: down: redis: 0s, normally up
    ok: down: sidekiq: 0s, normally up
    ok: down: unicorn: 0s, normally up
    [root@VM_0_5_centos ~]# ss -tnl

  2. I抦 impressed, I have to say. Actually rarely do I encounter a weblog that抯 each educative and entertaining, and let me inform you, you have hit the nail on the head. Your idea is excellent; the difficulty is something that not sufficient people are talking intelligently about. I’m very joyful that I stumbled throughout this in my search for something referring to this.

  3. Thank you for all of the work on this blog. My mum take interest in participating in investigations and it is obvious why. Almost all know all regarding the powerful method you offer reliable things on your blog and in addition foster participation from website visitors on that concept then our own princess is in fact being taught a great deal. Enjoy the rest of the new year. Your carrying out a very good job.

  4. I not to mention my guys appeared to be following the good guides located on the website then the sudden got an awful suspicion I never thanked you for those tips. All the ladies were definitely consequently happy to read them and now have absolutely been using them. Thank you for getting very considerate and for finding some beneficial issues millions of individuals are really needing to understand about. My very own honest regret for not expressing appreciation to sooner.

  5. I am only commenting to make you know what a fabulous encounter our daughter obtained using your web page. She came to understand numerous details, which included what it’s like to have a great giving mood to have certain people very easily grasp specific very confusing topics. You truly surpassed people’s expected results. I appreciate you for supplying such powerful, trusted, explanatory and even cool tips on your topic to Tanya.

  6. I’m just writing to make you understand of the notable discovery my girl encountered visiting the blog. She came to find numerous details, most notably how it is like to have an incredible coaching mood to have the rest completely fully understand some impossible things. You undoubtedly surpassed her desires. Thank you for rendering those important, dependable, educational and fun tips about this topic to Sandra.

  7. I want to get across my respect for your kind-heartedness giving support to individuals that actually need help on the content. Your personal commitment to passing the message all-around ended up being definitely good and have surely allowed professionals much like me to achieve their targets. Your helpful guideline indicates a great deal to me and additionally to my peers. With thanks; from each one of us.

  8. I simply wished to say thanks once more. I do not know the things that I would have sorted out without these suggestions shown by you about such concern. This has been an absolute frightful issue in my opinion, however , seeing a skilled fashion you resolved that forced me to leap with joy. Now i am happier for this work and trust you realize what a powerful job that you are putting in instructing some other people through your web site. Most probably you’ve never encountered any of us.

  9. I’m just writing to make you know of the great discovery my wife’s princess went through browsing the blog. She learned too many details, most notably what it’s like to possess an ideal giving character to let others without problems understand a number of hard to do subject matter. You really exceeded her expectations. Many thanks for rendering these practical, safe, explanatory and unique guidance on that topic to Julie.

  10. My husband and i have been so lucky Raymond could complete his research through the ideas he made using your web page. It’s not at all simplistic to just be giving away helpful hints which often most people have been trying to sell. And we also consider we have got the writer to thank for this. All of the illustrations you have made, the straightforward website navigation, the friendships your site assist to engender – it’s got mostly remarkable, and it’s assisting our son and the family do think that situation is satisfying, and that is exceedingly important. Thank you for the whole lot!

  11. I am also commenting to let you be aware of of the beneficial encounter my friend’s princess experienced visiting your web page. She came to find so many pieces, with the inclusion of how it is like to possess a marvelous coaching mindset to get the rest without problems gain knowledge of certain complex subject areas. You actually surpassed readers’ expectations. I appreciate you for showing the important, dependable, edifying and fun guidance on that topic to Ethel.

发表评论

邮箱地址不会被公开。