centos中部署gitlab
安装sshd
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
配置防火墙
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
vim /etc/sysctl.conf
systemctl enable firewalld
systemctl start firewalld
防火墙对http放行
firewall-cmd --permanent --add-service=http
systemct reload firewalld
安装 postfix
GitLab 需要使用 postfix 来发送邮件。也可以使用 SMTP 服务器。
yum install -y postfix
vim /etc/postfix/main.cf
119 inet_protocols = ipv4
需要将all改成ipv4
启用postfix
systemctl enable postfix
systemctl start postfix
安装gitlab
将源改为国内源
vim /etc/yum.repos.d/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
yum clean all
yum makecache fash
yum -y install gitlab-ce --nogpgcheck
安装完成后修改配置文件
vim /etc/gitlab/gitlab.rb
在大概32行修改成 http://192.168.5.6:8090
初始化gitlab
gitlab-ctl reconfigure
启动gitlab
gitlab-ctl start
重启 gitlab
gitlab-ctl restart
查看gitlab状态
gitlab-ctl status
修改配置文件后一定要初始化后再进行重启操作
gitlab-ctl reconfigure
gitlab-ctl restart
登录
http://192.168.5.6:8090/
用户名:root
进去以后修改密码,这个24小时后会删除
密码;
cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: FILZ2PFZmg0uw5c8aBdHahx1Nx9xcEz5MZo+lFYjuxQ=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
web界面修改成中文
配置git进行项目传输
配置秘钥
ssh-keygen -t rsa -C "gitlab用户名"
cd ~/.ssh
将生成的id_rsa.pub,将文件里面的秘钥添加到
通过git将项目传到gitlab中
git init
git remote add origin 项目地址
git add .
git commit -m "测试git上传项目"
git push -uf origin main
git上传遇到的问题
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to
需要
git pull --rebase origin main
然后
git init
git add .
git commit -m "测试git上传项目"
在windows上用git上传的话会看到
Administrator@DESKTOP-4Q366NS MINGW64 /d/项目/yolov5_main (main|REBASE 1/2)
执行git rebase --continue
会看到 (main|REBASE 1/2)变成main
然后重新进行上传
git push -uf origin main
上图标记的一定要和远程仓库的分支名称一样
不一样需要切换过来
git branch -m master main