gitlab安装与常用操作

/ 随笔 / 0 条评论 / 431浏览
  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.36.91:9083'
  1. 启动
#使配置生效
gitlab-ctl reconfigure
#查看服务状态
gitlab-ctl status
  1. 访问,使用
配置的链接 http://10.2.36.91: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

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

  1. 推送已有代码到gitlab
#Push an existing folder
cd existing_folder
git init
git remote add origin git@10.2.36.91: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.36.91: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?