持续集成git仓库

    技术2022-09-02  82

      

    1.Devops介绍   

      01.Devops是什么

    开发:development 运维:operations

    02.Devops能干嘛

    提高产品质量 01.自动化测试 02.持续集成 03.代码质量管理工具 04.程序员鼓励师

    03.Devops如何实现

    既然这么好?为什么有些公司没有 设计架构规划-代码的存储-构建-测试、预生产、部署、监控

    2.Git版本控制系统

    01.版本控制系统简介

    vcs `version control system` 版本控制系统是一种记录一个或若干个文件内容变化,以便将来查阅特定版本内容情况的系统 记录文件的所有历史变化 随时可恢复到任何一个历史状态 多人协作开发

    02.为什么需要版本控制系统

    03.常见版本管理工具

    SVN 集中式的版本控制系统,只有一个中央数据仓库,如果中央数据仓库挂了或者不可访问,所有的使用者无法使用SVN,无法进行提交或备份文件。

    Git 分布式的版本控制系统,在每个使用者电脑上就有一个完整的数据仓库,没有网络依然可以使用Git,当然为了习惯及团队协作,会将本地数据同步到Git服务器或者Github等代码仓库。

    04.牛逼的人不需要解释这句话被LINUX展现的淋漓尽致

    年轻时的托瓦兹

    3.Git安装

    01.系统环境准备

    [root@git ~]# cat /etc/redhat-release  CentOS Linux release 7.5.1804 (Core)  [root@git ~]# uname -r   #查看内核版本信息 3.10.0-862.el7.x86_64 [root@git ~]# getenforce   #确认Selinux是否关闭 Disabled [root@git ~]# systemctl stop firewalld

    02.Git部署安装

    [root@git ~]# yum install -y git [root@git ~]# rpm -qa git   #检查是否安装成功 git-1.8.3.1-23.el7_8.x86_64 [root@git ~]# git config --global     使用全局配置文件             --system     使用系统级配置文件             --local      使用版本库级配置文件 [root@git ~]# git config --global user.name "abin"               #配置git使用用户 [root@git ~]# git config --global user.email "abin@mail.com"     #配置git使用邮箱 [root@git ~]# git config --global color.ui true                  #语法高亮 [root@git ~]# git config --list user.name=abin user.email=abin@mail.com color.ui=true

    03.Git初始化

    初始化工作目录,对已存在的目录或者对已存在的目录都可进行初始化

    mkdir git_data cd git_data/ #初始化 git init [root@git ~/git_data]# ll -a total 4 drwxr-xr-x  3 root root   18 Jul  2 18:32 . dr-xr-x---. 7 root root 4096 Jul  2 18:32 .. drwxr-xr-x  7 root root  119 Jul  2 18:32 .git    #有此目录说明已经是仓库 #查看工作区状态 git status 隐藏文件介绍: branches #分支目录 config   #定义项目特有的配置选项 description    #仅供git web程序使用 HEAD    #指示当前分支 hooks   #包含git钩子文件 info    #包含一个全局排除文件(exclude文件) objects #存放所有数据内容,有info和pack两个子文件夹 refs    #存放指向数据(分支)的提交对象的指针 index   #保存暂存区信息,在执行git init的时候,这个文件还没有 [root@git ~/git_data]# tree .git     --git_data/工作目录 .git ├── branches ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │   ├── post-update.sample │   ├── pre-applypatch.sample │   ├── pre-commit.sample │   ├── prepare-commit-msg.sample │   ├── pre-push.sample │   ├── pre-rebase.sample │   └── update.sample ├── info │   └── exclude ├── objects     --本地仓库 │   ├── info │   └── pack └── refs        --暂存区     ├── heads   --头部     └── tags    --指针标签 9 directories, 13 files 数据保存到本地仓库前要经过暂存区

    4.Git常规使用

    01.创建数据-提交数据

    02.四种状态

    03.git基础命令

    [root@git ~/git_data]# git status     --查看工作区状态 # 位于分支 master # 初始提交 无文件要提交(创建/拷贝文件并使用"git add" 建立跟踪) [root@git ~/git_data]# git status # On branch master     --位于分支 master # # Initial commit     --初始提交 # # Untracked files:   --未跟踪的文件 #   (use "git add <file>..." to include in what will be committed) #          --(使用"git add <file>..."以包含要提交的内容) #    a #    b #    c nothing added to commit but untracked files present (use "git add" to track)   --使用git add进行跟踪

    将文件添加到暂存区

    [root@git ~/git_data]# git add a    --将a文件提交到暂存区 [root@git ~/git_data]# tree .git .git ├── branches ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │   ├── post-update.sample │   ├── pre-applypatch.sample │   ├── pre-commit.sample │   ├── prepare-commit-msg.sample │   ├── pre-push.sample │   ├── pre-rebase.sample │   └── update.sample ├── index                 --提交到暂存区以后出现index文件 ├── info │   └── exclude ├── objects │   ├── e6 │   │   └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 │   ├── info │   └── pack └── refs     ├── heads     └── tags 10 directories, 15 files [root@git ~/git_data]# git status # On branch master    #位于分支 master # # Initial commit    #初始提交 # # Changes to be committed:    #要提交的变更 #   (use "git rm --cached <file>..." to unstage)    #撤出暂存区 # #    new file:   a # # Untracked files: #   (use "git add <file>..." to include in what will be committed) # #    b #    c

    从暂存区撤出文件

    [root@git ~/git_data]# git rm --cached c rm 'c' [root@git ~/git_data]# git status # On branch master # # Initial commit # # Changes to be committed: #   (use "git rm --cached <file>..." to unstage) # #    new file:   a #    new file:   b # # Untracked files: #   (use "git add <file>..." to include in what will be committed) # #    c

    删除文件

    1.先从暂存区撤回到工作区、然后直接删除文件 git rm --cached c rm -f c 2.直接从暂存区域同工作区域一同删除文件命令 git rm -f b [root@git ~/git_data]# git commit -m "commit a"     #提交到本地仓库 [master (root-commit) 385b062] commit a  2 files changed, 0 insertions(+), 0 deletions(-)  create mode 100644 a  create mode 100644 b [root@git ~/git_data]# git status # On branch master    #位于分支 master # Untracked files:    #无文件要提交,干净的工作区 #   (use "git add <file>..." to include in what will be committed) # #    c nothing added to commit but untracked files present (use "git add" to track) [root@git ~/git_data]#

    未完续...

     

    Processed: 0.010, SQL: 9