gitlab 安装与使用

1、配置yum源
vim /etc/yum.repos.d/gitlab-ce.repo
复制以下内容:
 
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0

enabled=1

 

2、更新本地yum缓存
sudo yum makecache


3、安装GitLab社区版
sudo yum install gitlab-ce        #自动安装最新版
sudo yum install gitlab-ce-x.x.x    #安装指定版本

 

--启动

sudo gitlab-ctl reconfigure

sudo gitlab-ctl start

---本机访问 gitlab程序的ip 我安装在局域网 192.168.1.100  默认使用端口80

http://192.168.1.100

----------------修改默认启动端口

vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件

把这个external_url 'http://gitlab.example.com' 改成

external_url 'http://localhost:9000'

sudo gitlab-ctl stop

sudo gitlab-ctl reconfigure 

sudo gitlab-ctl start

访问

http://192.168.1.100:9000

GitLab常用命令
sudo gitlab-ctl start    # 启动所有 gitlab 组件;
sudo gitlab-ctl stop        # 停止所有 gitlab 组件;
sudo gitlab-ctl restart        # 重启所有 gitlab 组件;
sudo gitlab-ctl status        # 查看服务状态;
sudo gitlab-ctl reconfigure        # 启动服务;
sudo vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;

sudo gitlab-ctl tail        # 查看日志;

-------------------原分享地址   https://www.cnblogs.com/weifeng1463/p/7714492.html

4: 修改git仓库路径

默认Git repositories in /var/opt/gitlab/git-data

--步骤

sudo gitlab-ctl stop

sudo rsync -av /var/opt/gitlab/git-data/repositories /new-path/git-data/

sudo gitlab-ctl reconfigure

sudo ls //new-path/git-data/

sudo gitlab-ctl start
 

5:查看系统版本

 cat /etc/issue 

6:添加用户以及添加项目和分享用户

---添加用户

保存即可,保存退出再编辑用户即可修改用户密码

-----添加项目

 

----创建新group

--团队项目

 

--项目添加成员

7:项目提交

到项目中

 

git init
git remote add origin http://192.168.1.100/{your_user}/imagical_class.git
git add .
git commit -m "First commit"
git push -u origin masterhttp://192.168.1.100/{your_user}/imagical_class.git
git add .
git commit -m "First commit"
git push -u origin master

 

8:添加firewall或者iptables的端口   CentOS 6 使用service CentOS 7使用systemctl

--firewall CentOS 7自带

systemctl status firewalld

---添加端口或服务

firewall-cmd --permanent --add-service=http

firewall-cmd --reload

firewall-cmd --list-services

 

--常用命令

 

firewall-cmd --version

查看所有打开的端口: 

firewall-cmd --zone=public --list-ports

--添加
firewall-cmd --zone=public --add-port=80/tcp --permanent   (--permanent永久生效,没有此参数重启后失效)
--重新载入
firewall-cmd --reload
--查看
firewall-cmd --zone=public --query-port=80/tcp
--删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

--iptables 安装

yum -y install iptables-services

--编辑配置文件

vi /etc/sysconfig/iptables

--添加端口

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

--启动:

service iptables restart      #Centos6

systemctl restart iptables      #Centos7

 

9:拉取项目

---------git 基础 , 运行拉取服务需要客户端安装git
----Git global setup
git config --global user.name "yourAccount"
git config --global user.email "yourAccount@excample.com"

----Create a new repository
git clone http://gitlab.example.com/test.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

----Existing folder
cd existing_folder
git init
git remote add origin http://gitlab.example.com/test.git
git add .
git commit -m "Initial commit"
git push -u origin master

----Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.example.com/test.git
git push -u origin --all
git push -u origin --tags

----git remote 移除远程库
git remote remove origin

10:gitlab启用https

 修改配置文件:vim /etc/gitlab/gitlab.rb

external_url 'https://10.10.10.63'    #启用https,默认是http

nginx['enable'] = true
nginx['redirect_http_to_https'] = true    #http重定向到https

nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"            #ssl证书路径

nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"    #ssl秘钥路径

11:关闭注册功能

以管理员身份登录进GitLab平台 

Admin Area --> settings --> Sign-Up Restrictions

Sign-up enbaled  关闭注册功能 去掉钩

Admin Area --> settings --> Sign-In Restrictions

Sign-in  enbaled  关闭登录功能 去掉钩

12:git打标签
git tag -a v0.0.1 -m "first version 0.0.1"
git push origin v0.0.1

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值