目录
一、版本控制概念
版本控制概念:记录开发文件的时间机器,更好的开发,挽回代码错误带来的损失。
分类:本地版本控制系统;集中化的版本控制系统CSV、Subversion(SVN);分布式版本控制系统GIT
产品:github公共的服务器;git纯命令行的软件;gitlab私有的git web服务器
二、Gitlab部署
(GitLab最新版下载安装_GitLab中文免费版-极狐GitLab中文官方网站)
Index of /gitlab-ce/yum/el7/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
1.安装和配置必须的依赖项
sudo yum install -y curl policycoreutils-python openssh-server perl
sudo systemctl enable sshd #开机自启动ssh程序
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
#安装 Postfix 以发送电子邮件通知
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
#关闭防火墙
sudo systemctl stop firewalld
sudo systemctl disable firewalld
2.下载并安装Gitlab
官网安装或者去清华镜像站下载rpm包
#配置极狐GitLab 软件源镜像。
curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-jh
3.配置Gitlab
gitlab-ctl reconfigure
4.访问浏览器http:192.168.172.137
5.推送密钥
密钥提示
粘贴这个地址,用于下载项目(文档容器)
生成密钥
[root@localhost ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:mcdZdYGvdJFNAJ6XQT5u3GC+td+4RLrAnyRa5n5wn00 root@localhost.localdomain The key's randomart image is: +---[RSA 2048]----+ | .o*+*| | . = *.| | + O .| | + o B * | | S + . O o| | o. .= oE| | *oo.o= | | = =.+o.+| | ..o.+ o.o| +----[SHA256]-----+ [root@localhost ~]# ls .ssh/ id_rsa id_rsa.pub [root@localhost ~]# cat .ssh/id_rsa.pub //查看并复制密钥 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZE334/Jr4QF84qjb8qTIC2f65XsI2++NUHo0C7TNGYp6K3bQK6YM2zJWt9UWusD2G3u/eEX+VksDCdxMcFRhhOyaAx/Yfnj5MC5bNhxTb89PM9ydhaTucSY1dsLwsmvfSd9cPhNmbAcjvYSLIi+ok+lnkuP08JciVLh9VlasYM34fEOusJZf7Ib+RD5z+t6BmIt6VtZb7afxb5fiyQKY1eO4JVbbqdCDJzE1xchmiAyUCBcgUDYaHtrTPrNes9ZHvs09M4qMAqC2hX/7D5KfK9xc/Ox5Z5I4yZByyuh7196KVuF+uddiwuWjefgZnRzibosmfmC721oqnds3g5Fjp root@localhost.localdomain
上传密钥
链接地址
用于命令行或客户端程序进行下载使用。
使用gitlab
图形操作: 可以创建文件,上传文件
命令行操作[root@localhost ~]# vim /etc/hosts 192.168.172.161 gitlab.example.com #域名解析 #克隆服务器的文件 #下载文件 [root@localhost ~]# git config --global user.name "git" [root@localhost ~]# git config --global user.name "git@gitlab.example.com" [root@localhost ~]# git clone git@gitlab.example.com:root/project_test1.git Cloning into 'project_test1'... The authenticity of host 'gitlab.example.com (192.168.172.161)' can't be established. ECDSA key fingerprint is SHA256:HumQuxOX0NOaT9s/Lx2oTdcp3WZ+HnK0xD0tJQJTm54. ECDSA key fingerprint is MD5:ef:0b:e0:47:5d:dc:ce:0e:d7:e4:e3:55:94:0a:63:ac. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'gitlab.example.com,192.168.172.161' (ECDSA) to the list of known hosts. remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), 10.50 KiB | 0 bytes/s, done. [root@localhost ~]# ls anaconda-ks.cfg project_test1 [root@localhost ~]# ls project_test1/ 1.php three.jpg #上传文件 [root@localhost ~]# cd project_test1/ [root@localhost project_test1]# ls 1.php three.jpg [root@localhost project_test1]# echo 123456 > 2.sh [root@localhost project_test1]# git init #初始化 Reinitialized existing Git repository in /root/project_test1/.git/ [root@localhost project_test1]# git remote add origin git@gitlab.example.com:root/project_test1.git fatal: remote origin already exists. [root@localhost project_test1]# git add . [root@localhost project_test1]# git commit -m '2022' #提交上传说明 [master 910e529] 2022 Committer: git@gitlab.example.com <root@localhost.localdomain> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 1 insertion(+) create mode 100644 2.sh [root@localhost project_test1]# git push -u origin master #上传 Counting objects: 4, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 314 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@gitlab.example.com:root/project_test1.git 0eb275c..910e529 master -> master Branch master set up to track remote branch master from origin.