gitlab安装
gitlab安装流程
1 2 3 4 5 6 7 8 9 | 官网 https: //about .gitlab.com /install/ #centos-7 安装流程 装之前关闭防火墙 selinux yum install -y curl policycoreutils-python openssh-server curl https: //packages .gitlab.com /install/repositories/gitlab/gitlab-ee/script .rpm.sh| bash <br>yum install gitlab-ee -y vim /etc/gitlab/gitlab .rb /external_url 'http://192.168.1.120' gitlab-ctl reconfigure gitlab-ctl status 安装完毕 |
二. http://192.168.1.120 打开页面设置密码
三.创建组--和项目
四 。添加SSH key
[root@node1 ~]# cat .ssh/id_rsa.pub
#删除远程仓库
[root@node1 data]# git remote
[root@node1 data]# git remote remove origin
五。创建提交3部曲
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root@node1 data] # touch test.txt [root@node1 data] # git add . [root@node1 data] # git commit -m 'newfile test' [master de646f9] newfile test 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test .txt [root@node1 data] # git push -u origin master Counting objects: 3, done . Compressing objects: 100% (2 /2 ), done . Writing objects: 100% (2 /2 ), 215 bytes | 0 bytes /s , done . Total 2 (delta 1), reused 0 (delta 0) To git@192.168.1.120: test /git_data .git 74d9a27..de646f9 master -> master Branch master set up to track remote branch master from origin. |
六。创建DEV用户
添加到test组
如果开发用户想推代码需要添加ssh key
1 2 | [root@node2 ~] # cat .ssh/id_rsa.pub ssh -rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDYTi+o3TMaTMqblJ8PzFK45x6psSCkxGZEtT1ZnRRBjQs1hkRdO1qZqoAswvI1Ha7eR33iQplgRUxRXR /FKfugR9xBp3iKYAElwBC2545XkPMPvERSMd8nMdDgjwqKkIOfcefBrFRBPfggCFoNlfAHUFjZIhTo3Sh30hgSTKxUzd7cpitHOoCVOHVCS/qiXgqR/VY2tzoxDEn4e82iOGN54JNUdy0n2zYXvR4WEcYg2LBVUvT +DHuD7dBPWgt4Dfi3mfbp4kLIhI /sPF6zORgtrZer6TJKVmzjSSGLiHSfAg02kgroOJ/RCu7cpgq +zQJwgPx4fjhIIQ6IqlIBav1 root@node2 |
在本机克隆仓库代码
1 | [root@node2 git_data] # git clone git@192.168.1.120:test/git_data.git |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 开发推送代码到gitlab 但是这种有问题 不能让开发直接推送到master 需要让他推送到分支上 [root@node2 git_data] # touch file.txt [root@node2 git_data] # git add . [root@node2 git_data] # git commit -m 'newfile' *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'root@node2.(none)' ) [root@node2 git_data] # git config --global user.email "dev@example.com" [root@node2 git_data] # git config --global user.name "dev" [root@node2 git_data] # git commit -m 'newfile' [master ef18a5a] newfile 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 file .txt [root@node2 git_data] # git push -u origin master Counting objects: 3, done . Compressing objects: 100% (2 /2 ), done . Writing objects: 100% (2 /2 ), 219 bytes | 0 bytes /s , done . Total 2 (delta 1), reused 0 (delta 0) remote: GitLab: You are not allowed to push code to protected branches on this project. To git@192.168.1.120: test /git_data .git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@192.168.1.120:test/git_data.git' |
创建分支,并且把分支推送到master
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [root@node2 git_data] # git checkout -b dev Switched to a new branch 'dev' [root@node2 git_data] # git branch * dev master [root@node2 git_data] # git push -u origin dev Counting objects: 3, done . Compressing objects: 100% (2 /2 ), done . Writing objects: 100% (2 /2 ), 219 bytes | 0 bytes /s , done . Total 2 (delta 1), reused 0 (delta 0) remote: remote: To create a merge request for dev, visit: remote: http: //192 .168.1.120 /test/git_data/merge_requests/new ?merge_request%5Bsource_branch%5D=dev remote: To git@192.168.1.120: test /git_data .git * [new branch] dev -> dev Branch dev set up to track remote branch dev from origin. |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构