centos

centos gitlab使用教程

小樊
35
2025-02-24 19:27:41
栏目: 智能运维

在CentOS系统上安装和使用GitLab的步骤如下:

安装GitLab

  1. 安装依赖
sudo yum install -y curl policycoreutils-python openssh-server
  1. 启动并启用SSH服务
sudo systemctl enable sshd
sudo systemctl start sshd
  1. 配置防火墙
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
  1. 添加GitLab的包仓库
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  1. 安装GitLab
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
sudo EXTERNAL_URL="http://10.20.0.116" yum install -y gitlab-ce

配置GitLab

vi /etc/gitlab/gitlab.rb
external_url 'http://your-gitlab-server-ip'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "your-email@example.com"
gitlab_rails['smtp_password'] = "your-password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'your-email@example.com'
gitlab-ctl reconfigure
gitlab-ctl restart

使用GitLab

  1. 登录GitLab

在浏览器中输入你的GitLab服务器IP地址,使用安装过程中设置的root密码登录。

  1. 创建新项目

登录后,点击顶部导航栏中的“New project”按钮,填写项目名称、描述等信息,选择可见性和初始化选项,然后点击“Create project”按钮。

  1. 上传代码

在项目页面中,点击“Upload file”按钮,选择要上传的文件,上传完成后点击“Commit changes”按钮。

  1. 克隆项目到本地

使用以下命令将远程仓库克隆到本地:

git clone http://your-gitlab-server-ip/username/project.git
  1. 基本Git命令
git clone http://your-gitlab-server-ip/username/project.git
git add .
git commit -m "Commit message"
git push origin master
git pull origin master
git checkout -b new-branch
git checkout master
git merge new-branch

以上步骤涵盖了在CentOS系统上安装、配置和使用GitLab的基本流程。请注意,具体步骤可能会因GitLab版本和服务器配置的不同而有所差异。建议参考GitLab的官方文档以获取更详细的指导。

0
看了该问题的人还看了