编辑
2025-10-31
部署文档
00
请注意,本文编写于 276 天前,最后修改于 271 天前,其中某些信息可能已经过时。

目录

gitlab部署
部署流程
GitLab初始配置
git部署
git的yum源
git常用命令
git分支操作
提交到gitlab仓库

gitlab部署

部署流程

# 部署依赖 yum install -y policycoreutils-python yum install -y curl policycoreutils openssh-server openssh-clients postfix # 安装gitlab包 rpm -ivh gitlab-ee-15.6.0-ee.0.el7.x86_64.rpm #配置 vi /etc/gitlab/gitlab.rb external_url 'http://192.168.44.110' #重新配置GitLab gitlab-ctl reconfigure #启动GitLab gitlab-ctl start #检查GitLab状态 gitlab-ctl status

GitLab初始配置

#查看密码: 密码会在24h后自动删掉,及时修改密码 cat /etc/gitlab/initial_root_password #开启端口 sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --permanent --add-port=22/tcp sudo firewall-cmd --permanent --add-port=8150/tcp sudo firewall-cmd --permanent --add-port=8075/tcp sudo firewall-cmd --reload #web端访问 http://192.168.110.64/

git部署

git的yum源

# 安装 CentOS 7 专用 EPEL 源 参考19的git源 [root@esh19 yum.repos.d]# cat endpoint.repo [endpoint] name=End Point repository baseurl=https://packages.endpointdev.com/rhel/$releasever/os/$basearch/ enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-endpoint-7 protect=0

git常用命令

# 1. git add 将文件添加到暂存区 # 2. git blame 报告哪些用户更改了文件的哪些部分。 # 3. git bisect 使用二分查找来查找引入错误的提交。 # 4. git checkout 切换到特定的分支 # 5. git clone 复制一个现有的 Git 仓库。 # 6. git commit 将暂存的更改提交到仓库。 # 7. git commit --amend 修改最近的提交。 # 8. git diff 查看本地未暂存更改与您克隆或拉取的最新版本之间的差异。 # 9. git init 初始化一个目录,以便 Git 将其跟踪为仓库。 # 10. git pull 获取在您上次克隆或拉取项目后用户所做的所有更改。 # 11. git push 更新远程引用 # 12. git reflog 显示 Git 引用日志的更改列表 # 13. git remote add 告诉 Git把GitLab 远程仓库链接到本地目录。 # 14. git log 按时间顺序显示提交列表。 # 15. git show 显示 Git 中对象的信息。 # 16. git merge 将一个分支的更改与另一个分支合并。 # 17. git rebase 重写分支的提交历史记录。 # 18. git reset 撤销提交,回滚提交历史,并从较早的提交继续。 # 19. git status 显示工作目录和暂存文件的状态。

git分支操作

# 1. 分支的好处 同时进行多个功能开发,提高了开发效率 各个分支在开发过程中,如果某个分支开发失败,不会对其他分支有任何影响,失败的分支删除重新开始即可。 # 2. 查看分支 git branch -v # 3. 创建分支 git branch develop # 4. 切换分支 git checkout develop -- 在develop分支添加新的内容,从暂存区保存到本地仓库,两个分支内容不一样 # 5. 合并分支(正常合并) git merge develop

提交到gitlab仓库

#提交暂存文件 git commit -m "i added text # git branch #提交分支到远程仓库中 git push origin fenzhi #合并分支 [root@localhost sample_1029]# git branch * fenzhi main [root@localhost sample_1029]# git checkout main [root@localhost sample_1029]# git merge fenzhi #main分支提交到远程仓库中 [root@localhost sample_1029]# git push

本文作者:小辉辉

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!