gitlab操作指南

时间:2022-04-27
本文章向大家介绍gitlab操作指南,主要内容包括概述、项目管理、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

概述

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

安装

依赖组件:ruby 1.9.3+,MySQL,git,redis, Sidekiq。 最低配置CPU 1G,RAM 1G+swap可以支持100用户。 对于安装这里不做讲解,https://about.gitlab.com/downloads/

注:默认同时安装了GitLab CI, 后然配置Apache的端口,MySQL的端口,注意如果默认端口80, 3306有占用,需要修改。就不截图 了。 这个包默认会安装独立的MySQL,如果需要配置已有Mysql数据库,那么请手工逐个安装各个组件。安装完成后,服务就启动了。 配置OS自动启动:

sudo update-rc.d gitlab defaults 21

一些常用的命令

root@ubuntu:/opt/gitlab-7.1.1-0# ./ctlscript.sh start

140818 00:31:57 mysqld_safe Logging to '/opt/gitlab-7.1.1-0/mysql/data/mysqld.log'.

140818 00:31:57 mysqld_safe Starting mysqld.bin daemon with databases from /opt/gitlab-7.1.1-0/mysql/data

/opt/gitlab-7.1.1-0/mysql/scripts/ctl.sh : mysql started at port 3307

/opt/gitlab-7.1.1-0/redis/scripts/ctl.sh : redis started at port 6379

/opt/gitlab-7.1.1-0/apps/gitlab/scripts/sidekiq.sh : gitlab_sidekiq started

Session terminated, terminating shell... ...terminated.

/opt/gitlab-7.1.1-0/apps/gitlabci/scripts/sidekiq.sh : gitlabci_sidekiq started

/opt/gitlab-7.1.1-0/apps/gitlabci/scripts/runner.sh : gitlabci_runner started

Syntax OK

/opt/gitlab-7.1.1-0/apache2/scripts/ctl.sh : httpd started at port 81

:/opt/gitlab-7.1.1-0 是Gitlab的安装目录

也可以查看GUI管理控制台 ./manager-linux-x64.run

项目管理

安装完成之后,输入我们的登录地址。

创建与Git项目初始化工作

如我们的gitLab的地址,http://gitlab.hiwemeet.com/

新建项目

可创建三种级别的Projects(private,public,internal):

我们选择创建一个私有项目:

上传项目

上传的时候可以配置ssh,也可以不用ssh的,大家根据实际需要。 然后使用github的客户端工具gitbash上传代码,用到的命令如下,也就是上图的截图:

Git global setup(Git全局设置):

git config --global user.name "testman"
git config --global user.email "testman@hotmail.com"

Create Repository(创建仓库)
mkdir common-util
cd common-util
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@127.0.0.1:devteam/common-util.git
git push -u origin master

//对于已存在Git项目:
cd existing_git_repo 
git remote add origin git@127.0.0.1:devteam/common-util.git 
git push -u origin master

添加项目成员

这个项目如果是私人的,如果你是合作开发,需要添加项目成员。打开项目的“setting”,在左边找到member,然后选择。

删除项目

进入项目页面“setting”,找到(Show it to me)点击一下,就会显示出红色区域,在最下面有按钮: “Remove project”。

附件:https://www.gitlab.cc/downloads/