一、注册
gitlab官网注册入口:
https://about.gitlab.com/downloads/#centos7
https://gitlab.com/users/sign_in
一般注册免费版即可
二、安装和配置依赖项 (必需)
官方centos7配置链接:https://about.gitlab.com/installation/#centos-7
1.安装软件
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
2.防火墙设置
sudo firewall-cmd –permanent –add-service=http
sudo systemctl reload firewalld
3.安装postfix发送通知邮件。(可跳过)
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
4.添加gitlab库及安装包。
官方方法:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
我的操作:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum repolist 查看库中是否有包
5.安装gitlab包
官方方法:(安装gitlab包。改变http://gitlab.example.com
的URL为你想访问的你的gitlab实例。安装将自动配置和URL开始gitlab。HTTPS需要在安装后附加配置)
sudo EXTERNAL_URL=”http://gitlab.example.com” yum install -y gitlab-ee
我的操作:
sudo yum install gitlab-ce 或 yum -y install gitlab-ce-8.14.4-ce.0.el7.x86_64.rpm
sudo gitlab-ctl reconfigure 自动配置文件权限,安装数据库(安装的时间很长)
三、访问
浏览器访问gitlab服务器网址 (GITLAB占用80端口,访问时直接访问IP就可以
,第一次会让你确认root账户登录的密码)
http://192.168.122.163
此图为确认密码后跳转的页面
接着,输入root ,及第一次设的密码即可
四、创建项目
此项目的存储库是空的。
如果已经有文件,可以使用下面的命令行指令来推送它们。
否则,你可以开始添加一个自述,许可证,或gitignore这个项目。
当主分支被自动保护时,您将需要拥有或拥有初始推送的主权限级别。
它将根据预定义的CI / CD配置自动构建、测试和部署应用程序。
Command line instructions
1.Git的全局设置
git config –global user.name “Administrator”
git config –global user.email “admin@example.com”
2.创建一个新的存储库
git clone git@gitlab.example.com:root/ali.git
cd ali
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master
3.现有文件夹方式
cd existing_folder
git init
git remote add origin git@gitlab.example.com:root/ali.git
git add .
git commit -m “Initial commit”
git push -u origin master
4.现有Git仓库方式
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.example.com:root/ali.git
git push -u origin –all
git push -u origin –tags
五、推送SSH秘钥
1.粘贴这个地址,用于下载项目(文档容器)
http://192.168.122.163/root/ali root后为项目名
2.客户端生成秘钥
ssh-keygen
cat .ssh/id_rsa.pub
s