您可以捐助,支持我们的公益事业。

1元 10元 50元





认证码:  验证码,看不清楚?请点击刷新验证码 必填



  求知 文章 文库 Lib 视频 iPerson 课程 认证 咨询 工具 讲座 Model Center   Code  
会员   
   
 
     
   
 订阅
  捐助
持续集成git仓库
 
作者:姚斌
  11274  次浏览      15
 2020-11-25  
 
编辑推荐:
本文主要介绍了Devops是什么?Devops能干嘛?Devops如何实现?Git版本控制系统简介,为什么需要版本控制系统,常见版本管理工具,Git安装以及Git常规使用。
本文来自于www.abins.cn,由火龙果软件Alice编辑、推荐。

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 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

删除文件

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]#
 
   
11274 次浏览       15
相关文章

每日构建解决方案
如何制定有效的配置管理流程
配置管理主要活动及实现方法
构建管理入门
相关文档

配置管理流程
配置管理白皮书
CM09_C配置管理标准
使用SVN进行版本控制
相关课程

配置管理实践
配置管理方法、工具与应用
多层次集成配置管理
产品发布管理
最新课程计划
信息架构建模(基于UML+EA)3-21[北京]
软件架构设计师 3-21[北京]
图数据库与知识图谱 3-25[北京]
业务架构设计 4-11[北京]
SysML和EA系统设计与建模 4-22[北京]
DoDAF规范、模型与实例 5-23[北京]
 
最新文章
git原理图解
Git分支管理实践
Git学习和项目应用实例
Git 天天用 但是 Git 原理你了解吗?
对比 Git 与 SVN,这篇讲的很易懂
最新课程
Git版本控制系统
配置管理与持续集成实践
配置管理方法、实践、工具与应用
持续集成与敏捷开发
配置管理实践(从组织级到项目级)
更多...   
成功案例
某单位研发中心 产品集成与服务平台
某电子制造商 配置管理与持续集成
北京 配置管理与持续集成实践
金雅拓 分布式持续集成工具链
北京 持续集成测试最佳实践
更多...