Gitlab的介绍及使用

Gitlab 
一、GitLab简介 
GitHub是2008年由Ruby on Rails编写而成,与业界闻名的Github类似;但要将代码上传到 GitHub上面,而且将项目设为私有还要收费。而 GitLab 则是开源免费的(社区版免费,企业版需要订阅),能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用。 
1.1 Gitlab提供的功能 
代码托管服务 
访问权限控制 
问题跟踪,bug的记录、跟踪和讨论 
Wiki,项目中一些相关的说明和文档 
代码审查,可以查看、评论代码 
1.2 Gitlab(Github)和Git区别 
Github和Git是两回事。 
Git是版本控制系统,Github是在线的基于Git的代码托管服务。 
GitLab 是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,可通过Web界面进行访问公开的或者私人项目. 
1.3 Github PK Sourceforge 
为什么现在Github这么火,以至于世界顶级公司和项目的源码很多都托管在Github上 
Why? 
颜值高 
简洁大方

2011年,Github已经取代Sourceforge,成为最活跃的代码交流社区。这意味着在Open Source Community(开源社区),Git取代了SVN已经成为事实。

1.3.1 Github界面

1.3.2 Sourceforge界面

二、Gitlab安装 
2.1 环境配置 
硬件: 
Centos-6.x系列_x86_64 
Mem建议至少2G 
软件: 
gitlab-ce.x86_64 0:8.8.0-ce 
server client 
192.168.201.131 192.168.201.130(作为测试端) 
本次采用yum安装方式 
2.2 安装 
1、关闭SELinux

下面的命令实现永久关闭SELinux

[[email protected] ~]# sed -i ‘s/^SELINUX=./#&/;s/^SELINUXTYPE=./#&/;/SELINUX=.*/a SELINUX=disabled‘ /etc/sysconfig/selinux

下面的命令实现临时关闭SELinux

[[email protected] ~]# setenforce 0 
setenforce: SELinux is disabled

永久修改下主机名,需要重启系统之后生效

[[email protected] ~]# vi /etc/sysconfig/network 
NETWORKING=yes 
HOSTNAME=git.server.com #修改成你自己的主机名

临时修改

[[email protected] ~]#hostname git.server.com

添加域名

[[email protected] ~]#cat /etc/hosts 
192.168.201.131 git.server.com 
2、关闭firewall

临时关闭

[[email protected] yum.repos.d]# iptables -F 
[[email protected] yum.repos.d]# /etc/init.d/iptables stop 
iptables: Setting chains to policy ACCEPT: nat filter [ OK ] 
iptables: Flushing firewall rules: [ OK ] 
iptables: Unloading modules: [ OK ]

永久关闭,需要下次重启系统之后生效

[[email protected] yum.repos.d]# chkconfig iptables off 
3、同步时间 
[[email protected] yum.repos.d]# ntpdate time.nist.gov 
10 Apr 11:00:04 ntpdate[40122]: step time server 216.229.0.179 offset 53747.856066 sec 
4、配置yum源 
[[email protected] yum.repos.d]# cat gitlab.repo 
[gitlab-ce] 
name=gitlab-ce 
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 
repo_gpgcheck=0 
gpgcheck=0 
enabled=1 
gpgkey=https://packages.gitlab.com/gpg.key 
注解: 
如果想要在centos7系列上安装,只需把el6修改成el7 
5、安装Gitlab 
[[email protected] yum.repos.d]# yum install curl openssh-server openssh-clients postfix cronie -y 
[[email protected] yum.repos.d]# yum install gitlab-ce-8.8.0 -y 
6、修改下配置文件 
[[email protected] ~]# vi /etc/gitlab/gitlab.rb 
external_url ‘http://git.server.com‘ 
external_url 修改成自己的ip或者域名

修改配置文件之后,需要重新是配置文件生效下,初始化下

[[email protected] ~]#gitlab-ctl reconfigure #这里会花费一定的时间 
Recipe: gitlab::gitlab-rails 
* execute[clear the gitlab-rails cache] action run 
- execute /opt/gitlab/bin/gitlab-rake cache:clear 
* execute[clear the gitlab-rails cache] action run 
- execute /opt/gitlab/bin/gitlab-rake cache:clear 
Recipe: gitlab::unicorn 
* service[unicorn] action restart 
- restart service service[unicorn] 
Recipe: gitlab::redis 
* ruby_block[reload redis svlogd configuration] action create 
- execute the ruby block reload redis svlogd configuration 
Recipe: gitlab::postgresql 
* ruby_block[reload postgresql svlogd configuration] action create 
- execute the ruby block reload postgresql svlogd configuration 
Recipe: gitlab::unicorn 
* ruby_block[reload unicorn svlogd configuration] action create 
- execute the ruby block reload unicorn svlogd configuration 
Recipe: gitlab::sidekiq 
* ruby_block[reload sidekiq svlogd configuration] action create 
- execute the ruby block reload sidekiq svlogd configuration 
Recipe: gitlab::gitlab-workhorse 
* service[gitlab-workhorse] action restart 
- restart service service[gitlab-workhorse] 
* ruby_block[reload gitlab-workhorse svlogd configuration] action create 
- execute the ruby block reload gitlab-workhorse svlogd configuration 
Recipe: gitlab::nginx 
* ruby_block[reload nginx svlogd configuration] action create 
- execute the ruby block reload nginx svlogd configuration 
Recipe: gitlab::logrotate 
* ruby_block[reload logrotate svlogd configuration] action create 
- execute the ruby block reload logrotate svlogd configuration

Running handlers: 
Running handlers complete 
Chef Client finished, 222/303 resources updated in 08 minutes 35 seconds

如果在此期间没有出现error,证明成功

7、启动Gitlab服务 
[[email protected] ~]# gitlab-ctl start 
ok: run: gitlab-workhorse: (pid 1407) 263s 
ok: run: logrotate: (pid 1403) 263s 
ok: run: nginx: (pid 1404) 263s 
ok: run: postgresql: (pid 1405) 263s 
ok: run: redis: (pid 1402) 263s 
ok: run: sidekiq: (pid 1400) 263s 
ok: run: unicorn: (pid 1401) 263s 
gitlab-workhorse这个“工作马”,就是gitlab-Git-http-server(GitlabV8.0出现,V8.2名称变更为Gitlab-workhorse) 
sidekiq 多线程启动 
unicorn是ruby的http server,可以通过http://localhost:8080端口访问 
重启服务的一些命令 
gitlab-ctl start|stop|status|restart 
8、登录 
http://192.168.201.131/users/sign_in 
由于第一次登陆,需要设置密码

登录

登录之后的界面

9、卸载 
重新安装清理 
1,卸载 
[[email protected] Gitlab-cn]# gitlab-ctl uninstall 
2,删除文件 
[[email protected] Gitlab-cn]#rm -rf /etc/gitlab/* /var/log/gitlab/ /var/opt/gitlab/ /opt/gitlab/ 
2.3 汉化 
查看版本 
[[email protected] .ssh]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 
8.8.0 
下载汉化包并汉化 
[[email protected] hanhua]# git clone https://gitlab.com/larryli/gitlab.git Gitlab-cn && cd Gitlab-cn

生成补丁,

[[email protected] Gitlab-cn]#git diff origin/8-8-stable origin/8-8-zh > /tmp/8.8.diff

备份/opt/gitlab/embedded/service目录下的gitlab-rails目录,该目录下的内容主要是web应用部分

[[email protected] Gitlab-cn]#cp -rf /opt/gitlab/embedded/service/gitlab-rails /tmp/gitlab-rails

关闭gitlab这个服务

打补丁

[[email protected] Gitlab-cn]#patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/8.8.diff 
。。。。 
patching file public/ci/build-canceled.svg 
patching file public/ci/build-failed.svg 
patching file public/ci/build-pending.svg 
patching file public/ci/build-running.svg 
patching file public/ci/build-skipped.svg 
patching file public/ci/build-success.svg 
patching file public/ci/build-unknown.svg 
patching file public/deploy.html 
至此打补丁完成

测试是否汉化成功 
[[email protected] ~]# gitlab-ctl start 
ok: run: gitlab-workhorse: (pid 1407) 263s 
ok: run: logrotate: (pid 1403) 263s 
ok: run: nginx: (pid 1404) 263s 
ok: run: postgresql: (pid 1405) 263s 
ok: run: redis: (pid 1402) 263s 
ok: run: sidekiq: (pid 1400) 263s 
ok: run: unicorn: (pid 1401) 263s 
登录 
http://192.168.201.131/users/sign_in

2.4 实战测试 
http客户端测试

创建测试目录

[[email protected] ~]# mkdir test2 
[[email protected] ~]# cd test

把服务器的上仓库clone下来

[[email protected] test2]# git clone http://git.server.com/root/test.git 
Cloning into ‘test‘... 
warning: You appear to have cloned an empty repository. 
Checking connectivity... done. 
[[email protected] test2]# ls 
test 

[[email protected] test2]# git config --global user.name "Administrator" 
[[email protected] test2]# git config --global user.email "[email protected]" 
[[email protected] test2]# cd test/ 
[[email protected] test]# ls 
[[email protected] test]# touch README.md 
[[email protected] test]# vi README.md 
[[email protected] test]# git add README.md 
[[email protected] test]# git commit -m "add README" 
[master (root-commit) 874889b] add README 
1 file changed, 1 insertion(+) 
create mode 100644 README.md 
[[email protected] test]# git push -u origin master 
Username for ‘http://git.server.com‘: root 
Password for ‘http://[email protected]‘: adminroot 
Counting objects: 3, done. 
Writing objects: 100% (3/3), 223 bytes | 0 bytes/s, done. 
Total 3 (delta 0), reused 0 (delta 0) 
To http://git.server.com/root/test.git 
* [new branch] master -> master 
Branch master set up to track remote branch master from origin. 
从web上查看test仓库下是否上传了README.md这个文件

上传成功 
ssh客户端测试

生成公钥

[[email protected] .ssh]# ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa. 
Your public key has been saved in /root/.ssh/id_rsa.pub. 
The key fingerprint is: 
d9:0d:43:2b:17:cc:3b:01:fa:c9:cb:2c:6e:b7:27:6d [email protected] 
The key‘s randomart image is: 
+--[ RSA 2048]----+ 
| .+o | 
| . .+o | 
| . . =o | 
| o *o+ | 
| S ... | 
| o . | 
| . +. | 
| ...o E | 
| ....= | 
+-----------------+ 
[[email protected] .ssh]# 
[[email protected] .ssh]# ls 
id_rsa id_rsa.pub 
[[email protected] .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoOLsYhPPlHPOnGh6SoVDPlVn2o8rfO55J60Gz7E0EDB0ugKgTu4VGOE8vVta7HH5exNAjw2UqHIliYcmVvrj5eFbvXLdLYGypiMfuP4H7dVwGXfxSzeG17aIbZma0fpB2bTQr3tN+nVA7tokVSmO+jC61/H6Qj9G1TEiedq0wtTuSQ8pza5hyeWRO9oi0W7ccZkYg7lSQ3Eo2n2/RJbmQHWdIcoBO8c64h5vq/gB1s7ZjHKUjSFvGTyHu7uYE6yD2PXylavLfq2FHUc4syV8yAvyW2ehgIcc+xDWMFC85SNuPvTOt0YNzG628gWB2lm+D8CPhZBUbz2IUkFN0jEdyQ== [email protected]

添加这个(如果是真实的域名,这步不需要做)

[[email protected] .ssh]# vi /etc/hosts 
192.168.201.131 git.server.com

测试是否可用

[[email protected] .ssh]# ssh -T [email protected] 
The authenticity of host ‘git.server.com (192.168.201.131)‘ can‘t be established. 
RSA key fingerprint is 45:1f:76:55:cb:72:fe:65:22:75:10:eb:d5:2e:35:d5. 
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added ‘git.server.com,192.168.201.131‘ (RSA) to the list of known hosts. 
Welcome to GitLab, Administrator! 
证明成功

拉取数据

[[email protected] .ssh]# git clone [email protected]:root/test.git 
Initialized empty Git repository in /root/.ssh/test/.git/ 
remote: Counting objects: 3, done. 
remote: Total 3 (delta 0), reused 0 (delta 0) 
Receiving objects: 100% (3/3), 223 bytes, done 
FAQ 
官方文档 
https://www.gitlab.com.cn/ 
英文版: 
https://git-scm.com/book/en/v2 
中文版: 
https://git-scm.com/book/zh/v2 
http://www.cnblogs.com/herry52/p/5680020.html

时间: 2024-07-31 14:23:07

Gitlab的介绍及使用的相关文章

Gitlab的介绍

什么是GitLab ?◆GitLab是一个开源分布式版本控制系统◆开发语言: Ruby◆功能:管理项目源代码.版本控制.代码复用与查找GitLab与GitHub的不同 ◆ Github分布式在线代码托管仓库,个人版本可直接在线免费使用,企业版本收费且需要服务器安装◆Gitlab 分布式在线代码仓库托管软件,分社区免费版本与企业收费版本,都需要服务器安装. Gitlab的优势和应用场景开源免费,适合中小型公司将代码放置在该系统中 品差异化的版本管理,离线同步以及强大分支管理功能 便捷的GUI操作界

gitlab 安装和基本介绍

一 安装gitlab 1 环境简介 官方相关介绍: 硬件要求. 存储必要的硬盘空间在很大程度上取决于您想要存储在GitLab中的存储库的大小,但根据经验,您应该至少拥有与您的所有存储库合并占用的空闲空间.如果您希望将来灵活扩展硬盘空间,请考虑使用LVM进行安装,以便在需要时添加更多硬盘.除了本地硬盘驱动器,您还可以安装支持网络文件系统(NFS)协议的卷.此卷可能位于文件服务器,网络连接存储(NAS)设备,存储区域网络(SAN)或Amazon Web Services(AWS)弹性块存储(EBS)

GitLab 介绍

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

[转] 基于Gitlab CI搭建持续集成环境

[From] https://blog.csdn.net/wGL3k77y9fR1k61T1aS/article/details/78798577 前言 本文是在12月12号迅雷@赵兵在前端早读课第三期Live中提到的关于CI构建的,可能这部分在不同公司由不同的岗位负责,刚好如果你没遇到你可以看看. @赵兵,来自迅雷前端团队.是一个热爱前端技术,喜欢造轮子,爱折腾的人,也是一个奉行"懒惰使人进步"的懒人工程师. 正文从这开始- 本文简单介绍了持续集成的概念并着重介绍了如何基于 Gitl

GitLab服务器IP地址修改

gitlab安装介绍:https://about.gitlab.com/downloads/#centos7 刚搭建好的gitlab在GitLab上新建一个项目test_gitlab,刚开始仓库地址是http://127.0.0.1/yulei/test_gitlab.git 我的centos7的连接ip是192.168.6.129 把localhost 换成本机的IP地址,修改方式如下: 修改gitlab.yml文件: cd /opt/gitlab/embedded/service/gitla

GitLab ci/cd部署环境构建

说明 本文简单介绍下 Gitlab CI,包括Gitlab Runner,Gitlab CI中的相关概念以及.gitlab-ci.yml的常用配置. 部署GitLab 请参考Docker-compose部署gitlab中文版 什么是 GitLab CI GitLab CI 是GitLab内置的进行持续集成的工具,只需要在仓库根目录下创建.gitlab-ci.yml文件,并配置GitLab Runner:每次提交的时候,gitlab将自动识别到.gitlab-ci.yml文件,并且使用Gitlab

【持续集成】GIT+jenkins+snoar——GIT

一.GIT基础 1.1 git简介 linux用C语言编写 2005年诞生 分布式管理系统 速度快.适合大规模.跨地区多人协同开发 1.2 本地管理.集中式.分布式 1.3 git安装 1 #CentOS上安装 2 [[email protected] ~]# yum -y install git 3 #Ubuntu上安装 4 [[email protected] ~]# apt-get install git 注:生产环境中,不建议这么安装,yum装的git版本是1.8,推荐使用2.7版本 编

从无到有项目开发过程—前期准备(软件的选用)

1. 服务器系统:centos 6.5 2. 反向代理:nginx-1.9.3 反向代理服务器是在服务器端设定的,主要用于隐藏服务器的真正信息和重定向请求.代理接受到请求时,判断代理服务器的配置信息,根据配置,重定向请求到真实的请求地址(同一台,另外一台,另外多台(集群)服务器上),以达到对外隐藏信息,以及负载均衡的目的. 如果没有使用代理服务器,我们在通过浏览器访问服务器得到的返回里面,如果没有刻意对返回头做修改,我们就可以看到服务器的相关信息,如下红框中的内容 3. 应用服务器:jboss

gitlab两种连接方式:ssh和http配置介绍

gitlab环境部署好后,创建project工程,在本地或远程下载gitlab代码,有两种方式:ssh和http (1)ssh方式:这是一种相对安全的方式 这要求将本地的公钥上传到gitlab中,如下图: window客户机设置ssh方式连接gitlab,请见:http://www.cnblogs.com/kevingrace/p/5651402.html(文章底部有介绍) (2)http连接方式 这种方式要求project在创建的时候选择"Public"或"Internal