当前位置:  首页>> 技术小册>> CI和CD代码管理平台实战

系统环境准备

系统:CentOS8

  1. [root@zutuanxue ~]# sestatus -v
  2. SELinux status: disabled
  3. [root@zutuanxue ~]# systemctl status firewalld
  4. firewalld.service - firewalld - dynamic firewall daemon
  5. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  6. Active: inactive (dead)
  7. Docs: man:firewalld(1)
  8. [root@zutuanxue ~]# dnf repolist
  9. 上次元数据过期检查:6:26:44 前,执行于 20200402 星期四 231737秒。
  10. 仓库标识 仓库名称 状态
  11. app app 4,681
  12. os os 1,655

Git安装部署

  1. [root@zutuanxue ~]# dnf install git
  2. Git 自带一个 git config 的工具来帮助设置控制 Git 外观和行为的配置变量。 这些变量存储在三个不同的位置:
  3. [root@zutuanxue ~]# git config
  4. --system 系统配置文件 配置内容会存放在/etc/gitconfig中,包含系统上每一个用户及他们的仓库的通用配置,需要管理员权限
  5. --global 全局配置文件 配置内容会存放在~/.gitconfig或者~/.config/git/gitconfig
  6. --local 本地的配置文件 配置文件存放在git工作目录的.git/config
  7. 注:配置文件的优先级local>global>system,可以使用git config -h去获取相关帮助,也可以使用git config --list --show-origin查看所有的配置及所在的文件。
  8. [root@zutuanxue ~]# git config --global user.name "hello"
  9. #定义git用户
  10. [root@zutuanxue ~]# git config --global user.email "hello@localhost
  11. #定义git使用的邮箱
  12. [root@zutuanxue ~]# git config --global color.ui true
  13. #定义语法高亮
  14. [root@zutuanxue ~]# git config --list
  15. user.name=hello
  16. user.email=hello@localhost
  17. color.ui=true
  18. #查看定义的信息
  19. [root@zutuanxue ~]# pwd
  20. /root
  21. [root@zutuanxue ~]# cat .gitconfig
  22. [user]
  23. name = hello
  24. email = hello@localhost
  25. [color]
  26. ui = true

git初始化

初始化工作目录、主要用来初始化一个空的git本地仓库。执行完上面的命令,当前目录下会自动生成.git隐藏文件夹,

  1. #建立工作目录
  2. mkdir git_data
  3. cd git_data/
  4. #初始化
  5. git init
  6. #查看工作区状态
  7. git status
  8. [root@zutuanxue git_data]# pwd
  9. /root/git_data
  10. [root@zutuanxue git_data]# git status
  11. 位于分支 master
  12. 尚无提交
  13. 无文件要提交(创建/拷贝文件并使用 "git add" 建立跟踪)
  14. 隐藏文件介绍:
  15. [root@zutuanxue git_data]# pwd
  16. /root/git_data
  17. [root@zutuanxue git_data]# ls -a
  18. . .. .git
  19. [root@zutuanxue git_data]# cd .git/
  20. [root@zutuanxue .git]# ls
  21. branches config description HEAD hooks info objects refs
  22. branches # 分支目录
  23. config # 保存配置信息
  24. description # 仅供git web程序使用
  25. HEAD # 记录当前的分支指向
  26. hooks # 包含脚本文件
  27. info # 包含一个全局排除文件(exclude文件),可以将不想被git处理的文件定义到exclude文件中
  28. objects # 存放所有数据内容 ,有info和pack两个子文件夹(实际也就是本地仓库的目录)
  29. refs # 这个目录一般包括三个子文件夹,heads、remotes和tags,heads中的文件标识了项目中的各个分支指向的当前哪一个提交记录
  30. index # 保存暂存区信息 ,在执行git init的时候 ,这个文件还没有(也就是暂存区的内容)

该分类下的相关小册推荐: