关闭防火墙
下载安装(rpm包的形式)
[root@centos ~]# yum install https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.5.2-ce.0.el7.x86_64.rpm
配置
将external_url变量的地址修改为gitlab所在centos的ip地址。
vim /etc/gitlab/gitlab.rb
邮箱(可省)
# vim /etc/gitlab/gitlab.rb
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_email_display_name'] = 'gitlab'
gitlab_rails['gitlab_email_from'] = '邮箱'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "邮箱"
gitlab_rails['smtp_password'] = "授权码"
gitlab_rails['smtp_domain'] = "smtp.163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
user["git_user_email"] = "邮箱"
因为修改了配置文件,故需要重新加载配置内容。
# gitlab-ctl reconfigure
# gitlab-ctl restart
创建群组
创建用户
1)需要点击邮箱--点开里面的网页---设置密码
2) 点编辑--
将用户加入组
创建项目
给yu增加权限
项目--设置--成员
Git 全局设置
另外一台机器当客户端
[root@localhost ~]# yum install git -y
[root@localhost ~]# git config --global user.name "yu"
[root@localhost ~]# git config --global user.email "邮箱"
[root@localhost ~]# git clone http://192.168.136.143/a-b-c/mygit.git
正克隆到 'mygit'...
Username for 'http://192.168.136.143': yu
Password for 'http://yu@192.168.136.143':
warning: 您似乎克隆了一个空版本库。
[root@localhost ~]# cd mygit/
[root@localhost mygit]# vi aaa.txt
可以把您的代码传进来
放入暂存区
提交 但还没到仓库里面
配置SSH
[root@localhost ~]# ssh-keygen -f ~/.ssh/id_rsa -P '' -q
[root@localhost ~]# cat ~/.ssh/id_rsa
id_rsa id_rsa.pub
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyuv9h/CV+0rGy5iFWc1ov3U4SmwRUJdKKK/bwqHVvrZa7Il5cVFYAMNq8mGuRuaKl5Rz++7DV7BM6z0ZijHzsZIsiLAEEsPWa9esUm4qCqT4qBYYOU/lqWgQ6IFmm8/DgS61ApAgn0xdjbvXfve/3JVQ6UueQU7CKg5qr3vCKDy+knAIC8SM9Thubulbqz69ZRlsFphTV+/cO693pkr5Aqyp2p97chjPqYCv1+OJTTjRINMhAkd9HBtoU4Ky9Xg8YymTugtdSuJL87ZOnD3cB7I31/BVA/RpgSJKMynuUieFMbQRMymyVH3IRZEyF9I+fSUAt6xHGZ39d1ykK6zzT root@localhost.localdomain
把公钥复制下来
当用户以后想要clone代码时,无需输入密码
[root@localhost ~]# mkdir /git_test
[root@localhost ~]# cd /git_test/
[root@localhost git_test]# git clone git@192.168.136.143:a-b-c/mygit.git
正克隆到 'mygit'...
The authenticity of host '192.168.136.143 (192.168.136.143)' can't be established.
ECDSA key fingerprint is SHA256:2U0fEWgGS/4x5kec5xiCBYBo7BCShwuVTN7o/8zvyi0.
ECDSA key fingerprint is MD5:4c:0a:ca:f5:ad:bc:92:31:32:b0:d0:0a:82:a0:24:d9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.136.143' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
接收对象中: 100% (3/3), done.
[root@localhost git_test]# ll
总用量 0
drwxr-xr-x. 3 root root 33 3月 26 11:31 mygit
[root@localhost git_test]# cd mygit/
[root@localhost mygit]# ll
总用量 4
-rw-r--r--. 1 root root 7 3月 26 11:31 aaa.txt
当用户想要上传代码时
[root@localhost mygit]# echo "web test page" > index.html
[root@localhost mygit]# git add .
[root@localhost mygit]# git commit -m 'index commit'
[master 9eb1957] index commit
1 file changed, 1 insertion(+)
create mode 100644 index.html
[root@localhost mygit]# git remote -v
origin git@192.168.136.143:a-b-c/mygit.git (fetch)
origin git@192.168.136.143:a-b-c/mygit.git (push)
[root@localhost mygit]# git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.136.143:a-b-c/mygit.git
78f4e42..9eb1957 master -> master