开发:development 运维:operations
提高产品质量 01.自动化测试 02.持续集成 03.代码质量管理工具 04.程序员鼓励师
既然这么好?为什么有些公司没有 设计架构规划-代码的存储-构建-测试、预生产、部署、监控
vcs `version control system` 版本控制系统是一种记录一个或若干个文件内容变化,以便将来查阅特定版本内容情况的系统 记录文件的所有历史变化 随时可恢复到任何一个历史状态 多人协作开发
SVN 集中式的版本控制系统,只有一个中央数据仓库,如果中央数据仓库挂了或者不可访问,所有的使用者无法使用SVN,无法进行提交或备份文件。
Git 分布式的版本控制系统,在每个使用者电脑上就有一个完整的数据仓库,没有网络依然可以使用Git,当然为了习惯及团队协作,会将本地数据同步到Git服务器或者Github等代码仓库。
年轻时的托瓦兹
[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
[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
初始化工作目录,对已存在的目录或者对已存在的目录都可进行初始化
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 数据保存到本地仓库前要经过暂存区将文件添加到暂存区
[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]#未完续...
