GitLab搭建与使用简介

本文详述了如何在Linux系统中通过yum安装GitLab,并配置外部访问地址。接着介绍了GitLab的启动、状态检查以及常用管理命令。此外,还讲解了GitLab的用户权限级别和项目访问权限设置。最后,提供了将现有代码推送到GitLab仓库的步骤,以及如何更新已fork的仓库。
摘要由CSDN通过智能技术生成
  1. 新建 /etc/yum.repos.d/gitlab_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
  1. 安装
sudo yum install gitlab-ce
  1. GitLab配置文件修改
vim /etc/gitlab/gitlab.rb

#修改访问地址
external_url 'http://10.2.20.20:9083'
  1. 启动
#使配置生效
gitlab-ctl reconfigure
#查看服务状态
gitlab-ctl status
  1. 访问,使用
配置的链接 http://10.2.20.20:9083
  1. 常用命令
gitlab-ctl start    # 启动所有 gitlab 组件;
gitlab-ctl stop        # 停止所有 gitlab 组件;
gitlab-ctl restart        # 重启所有 gitlab 组件;
gitlab-ctl status        # 查看服务状态;
vim /etc/gitlab/gitlab.rb        # 修改gitlab配置文件;
gitlab-ctl reconfigure        # 重新编译gitlab的配置;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
gitlab-ctl tail        # 查看日志;
gitlab-ctl tail nginx/gitlab_access.log
  1. Gitlab权限管理

Gitlab用户在组中有五种权限:Guest、Reporter、Developer、Master、Owner

  • Guest:可以创建issue、发表评论,不能读写版本库
  • Reporter:可以克隆代码,不能提交,QA、PM可以赋予这个权限
  • Developer:可以克隆代码、开发、提交、push,RD可以赋予这个权限
  • Master:可以创建项目、添加tag、保护分支、添加项目成员、编辑项目,核心RD负责人可以赋予这个权限
  • Owner:可以设置项目访问权限 - Visibility Level、删除项目、迁移项目、管理组成员,开发组leader可以赋予这个权限

Gitlab中的组和项目有三种访问权限:Private、Internal、Public

  • Private:只有组成员才能看到
  • Internal:只要登录的用户就能看到
  • Public:所有人都能看到
  1. 推送已有代码到gitlab
#Push an existing folder
cd existing_folder
git init
git remote add origin git@10.2.20.20:adaivskenan/newrpo.git
git add .
git commit -m "Initial commit"
git push -u origin master

#Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin git@10.2.20.20:adaivskenan/newrpo.git
git push -u origin --all
git push -u origin --tags
  1. 更新自己fork的仓库
# 下面操作是更新master,如果更新别的分支,要在对应分支操作,
# 比如develop,只需要把下面命令的master全部替换为develop

# Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:

git fetch upstream

# Make sure that you're on your master branch:

git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:

git rebase upstream/master

# If you've rebased your branch onto upstream/master you may need
# to force the push in order to push it to your own forked repository

git push -f origin master

参考

How do I update a GitHub forked repository?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值