首页 > 其他分享 >私有远程仓库Gitlab

私有远程仓库Gitlab

时间:2022-08-30 21:26:08浏览次数:86  
标签:origin git 私有 com Gitlab rails gitlab root 远程

私有远程仓库Gitlab

Gitlab介绍

  • 私有代码仓库,除了Gitlab还有gogs
  • 精细化的权限配置
  • 控制用户/用户组权限,避免任何用户都可以将代码提交master

Gitlab的架构

部署Gitlab-ce

# 使用清华源,直接安装
[root@gitlab ~]# yum install -y https://mirrors.tuna.tsinghua.edu.cn/gitlabce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

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

# 安装过程
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

# 1.修改配置文件
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.wc.com'

# 添加邮箱相关配置
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'wc gitlab notice'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "dizyzzjjujhxdefe"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
prometheus['enable'] = false
prometheus['monitor_kubernetes'] = false
prometheus_monitoring['enable'] = false
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
gitlab_monitor['enable'] = false
grafana['enable'] = false
alertmanager['enable'] = false

# 2.重新加载配置文件
[root@gitlab ~]# gitlab-ctl reconfigure

Chef Client finished, 299/430 resources updated in 02 minutes 28 seconds
gitlab Reconfigured!

Gitlab操作

# 查看当前服务状态
[root@gitlab git]# gitlab-ctl status

# 停止所有服务
[root@gitlab git]# gitlab-ctl stop

# 启动所有服务
[root@gitlab git]# gitlab-ctl start

# 重启所有服务
[root@gitlab git]# gitlab-ctl restart

# 停止指定服务
[root@gitlab git]# gitlab-ctl stop nginx

# 启动指定服务
[root@gitlab git]# gitlab-ctl start nginx

# 查看Gitlab所有组件日志
[root@gitlab git]# gitlab-ctl tail

# 查看Gitlab指定组件日志
[root@gitlab git]# gitlab-ctl tail nginx

# 连接Gitlab终端
[root@gitlab git]# gitlab-rails console

# 测试发邮件
irb(main):012:0> Notify.test_email('[email protected]','sbsbsb','hei/hei/hei').deliver_now

# 忘记root密码
[root@gitlab git]# gitlab-rails console
## 登录root用户
irb(main):011:0> user = User.where(id: 1).first
irb(main):012:0> user.password='123456789'
irb(main):012:0> user.password_confirmation='123456789'
irb(main):012:0> user.save


Gitlab汉化

汉化官网:TP

# 1.下载汉化包
[root@gitlab ~]# wget https://gitlab.com/xhang/gitlab/-/archive/10-2-stable-zh/gitlab10-2-stable-zh.tar.gz

# 2.解压汉化包
[root@gitlab ~]# tar xf gitlab-10-2-stable-zh.tar.gz

# 3.停止所有服务
[root@gitlab ~]# gitlab-ctl stop

# 4.覆盖
[root@gitlab ~]# \cp -a gitlab-10-2-stable-zh/* /opt/gitlab/embedded/service/gitlabrails/

# 5.重新加载配置文件
[root@gitlab ~]# gitlab-ctl reconfigure

# 6.启动所有服务
[root@gitlab ~]# gitlab-ctl start



创建项目

HTTP命令行指令
 
Git 全局设置
git config --global user.name "Administrator"
git config --global user.email "[email protected]"

创建新版本库
git clone http://gitlab.zls.com/root/linux2.git
cd linux2
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

已存在的文件夹
cd existing_folder
git init
git remote add origin http://gitlab.zls.com/root/linux2.git
git add .
git commit -m "Initial commit"
git push -u origin master

已存在的 Git 版本库
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.zls.com/root/linux2.git
git push -u origin --all
git push -u origin --tags

SSH命令行指令

Git 全局设置
git config --global user.name "Administrator"
git config --global user.email "[email protected]"

创建新版本库
git clone [email protected]:root/linux2.git
cd linux2
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

已存在的文件夹
cd existing_folder
git init
git remote add origin [email protected]:root/linux2.git
git add .
git commit -m "Initial commit"
git push -u origin master

已存在的 Git 版本库
cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:root/linux2.git
git push -u origin --all
git push -u origin --tags

添加git远程仓库

# 1.添加远程仓库
[root@gitlab web]# git remote add zls [email protected]:root/linux2.git

# 2.添加hosts解析
[root@gitlab web]# vim /etc/hosts
10.0.0.91 gitlab.zls.com

# 3.生成秘钥
[root@gitlab git]# ssh-keygen

# 4.查看公钥
[root@gitlab git]# cat ~/.ssh/id_rsa.pub

# 5.网页添加ssh秘钥




Gitlab创建用户和用户组




下载Gitlab仓库的代码

# 克隆代码
[root@gitlab opt]# git clone [email protected]:ops/new_linux2.git

# 同步仓库代码跟gitlab中保持一致
[root@gitlab new_linux2]# git pull

# 拉所有分支代码
[root@gitlab new_linux2]# git fetch -vp

标签:origin,git,私有,com,Gitlab,rails,gitlab,root,远程
From: https://www.cnblogs.com/wangchengww/p/16640832.html

相关文章