Gitlab+Jenkins学习之路(一)之Git基础

  • 1、GIT基础

GIT是一个分布式版本管理系统,速度快,适合大规模,跨地区多人协同开。SVN是一个集中式版本管理系统。

(1)GIT生态

GIT分布式版本管理系统

Gitlab git私库解决方案

Github git公有库解决方案

(2)Git安装

Centos:

yum install -y git

Ubuntu:

apt-get install git

Windows安装git bash

Linux编译安装

注意不要使用git 1.8以下版本,推荐使用2.7版本

1①编译安装git[root@linux-node1 ~]# yum install -y epel-release 2安装依赖包: 3[root@linux-node1 ~]# yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker 4[root@linux-node1 ~]# wget https://github.com/git/git/archive/v2.7.4.zip 5[root@linux-node1 ~]# yum install -y unzip 6[root@linux-node1 ~]# unzip git-v2.7.4.zip 7[root@linux-node1 ~]# cd git-2.7.4 8[root@linux-node1 git-2.7.4]# make prefix=/usr/local/git all 9[root@linux-node1 git-2.7.4]# make prefix=/usr/local/git install 10[root@linux-node1 git-2.7.4]# rm -rf /usr/bin/git 11[root@linux-node1 git-2.7.4]# ln -s /usr/local/git/bin/git /usr/bin/git 12[root@linux-node1 git-2.7.4]# git --version 13git version 2.7.4 14 15②初始化仓库 16[root@linux-node1 ~]# mkdir test 17[root@linux-node1 ~]# cd test 18[root@linux-node1 test]# git init #将test目录初始化仓库 19[root@linux-node1 test]# git config --global user.name"*****" 20[root@linux-node1 test]# git config --global user.email *******@qq.com 21 22四个区域: 23远程仓库<-->本地仓库<-->暂存区域<-->工作目录 24 25四种状态 26Untracked、Unmodified、Modified、Staged 27Untracked(工作目录)-->git add -->Staged(暂存区)-->git commit版本-->Unmodified(本地仓库)-->Edit file-->Modified-->Stage the file-->Staged 28 29③常用命令: 30git add 加入暂存 31git status 查看状态 32git status -s 状态概览 33git diff 尚未暂存的文件 34git diff --staged 暂存区文件 35git commit 提交更新 36git reset 回滚 37git rm 从版本库中移除 38git rm --cached README 从暂存区中移除 39git mv 相当于mv git rm git add 三个命令 40 41使用演示: 42[root@linux-node1 test]# touch index.html ==>创建文件 43[root@linux-node1 test]# vim index.html 44[root@linux-node1 test]# git status ==>此时文件处于工作目录中 45位于分支 master 46 47初始提交 48 49未跟踪的文件: 50 (使用 "git add <文件>..." 以包含要提交的内容) 51 52 index.html 53 54提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪) 55[root@linux-node1 test]# git add index.html ==>加入代码库 56[root@linux-node1 test]# git status ==>此时文件处于暂存区 57位于分支 master 58 59初始提交 60 61要提交的变更: 62 (使用 "git rm --cached <文件>..." 以取消暂存) 63 64 新文件: index.html 65 66[root@linux-node1 test]# git commit -m "first commit" ==>提交到本地仓库 67[master(根提交) c6bc04f] first commit 68 1 file changed, 3 insertions(+) 69 create mode 100644 index.html 70[root@linux-node1 test]# git status 71位于分支 master 72无文件要提交,干净的工作区 73[root@linux-node1 test]# git log 74commit c6bc04f90d4ef442e2c4d5bc788b21de239332da ==>回滚需要的id 75Author: ****** <******@qq.com> 76Date: Fri Dec 8 22:37:40 2017 +0800 77 78 first commit 79 80[root@linux-node1 test]# touch pay.html 81[root@linux-node1 test]# vim pay.html 82[root@linux-node1 test]# git add pay.html 83[root@linux-node1 test]# git status 84On branch master 85Changes to be committed: 86 (use "git reset HEAD <file>..." to unstage) 87 88 new file: pay.html 89 90[root@linux-node1 test]# touch news.html 91[root@linux-node1 test]# echo "123" > news.html 92[root@linux-node1 test]# git status 93On branch master 94Changes to be committed: 95 (use "git reset HEAD <file>..." to unstage) 96 97 new file: pay.html 98 99Untracked files: 100 (use "git add <file>..." to include in what will be committed) 101 102 news.html 103 104[root@linux-node1 test]# git add news.html 105[root@linux-node1 test]# git status 106On branch master 107Changes to be committed: 108 (use "git reset HEAD <file>..." to unstage) 109 110 new file: news.html 111 new file: pay.html 112 113[root@linux-node1 test]# git rm --cached pay.html #将pay.html从暂存区移除 114rm 'pay.html' 115[root@linux-node1 test]# git status 116On branch master 117Changes to be committed: 118 (use "git reset HEAD <file>..." to unstage) 119 120 new file: news.html 121 122Untracked files: 123 (use "git add <file>..." to include in what will be committed) 124 125 pay.html 126 127[root@linux-node1 test]# git commit -m "news" 128[master d83603a] news 129 1 file changed, 1 insertion(+) 130 create mode 100644 news.html 131[root@linux-node1 test]# git status 132On branch master 133Untracked files: 134 (use "git add <file>..." to include in what will be committed) 135 136 pay.html 137 138nothing added to commit but untracked files present (use "git add" to track) 139[root@linux-node1 test]# git log 140commit d83603a56b8926630d31b46898e4b6d69293d946 141Author:******** 142Date: Fri Dec 8 22:48:37 2017 +0800 143 144 news 145 146commit c6bc04f90d4ef442e2c4d5bc788b21de239332da 147Author: ***************** 148Date: Fri Dec 8 22:37:40 2017 +0800 149 150 first commit 151[root@linux-node1 test]# echo "66666" >> pay.html 152[root@linux-node1 test]# git status 153On branch master 154Untracked files: 155 (use "git add <file>..." to include in what will be committed) 156 157 pay.html 158 159nothing added to commit but untracked files present (use "git add" to track) 160[root@linux-node1 test]# git add pay.html 161[root@linux-node1 test]# git status 162On branch master 163Changes to be committed: 164 (use "git reset HEAD <file>..." to unstage) 165 166 new file: pay.html 167 168[root@linux-node1 test]# git commit -m "pay modelue" 169[master e55a302] pay modelue 170 1 file changed, 2 insertions(+) 171 create mode 100644 pay.html 172[root@linux-node1 test]# git status 173On branch master 174nothing to commit, working directory clean 175[root@linux-node1 test]# git log 176commit e55a302e11d967fd25eac1cce8b6c7bed732019b 177Author:****************** 178Date: Fri Dec 8 22:49:57 2017 +0800 179 180 pay modelue 181 182commit d83603a56b8926630d31b46898e4b6d69293d946 183Author: ****************** 184Date: Fri Dec 8 22:48:37 2017 +0800 185 186 news 187 188commit c6bc04f90d4ef442e2c4d5bc788b21de239332da 189Author: ****************** 190Date: Fri Dec 8 22:37:40 2017 +0800 191 192 first commit
  • 2、分支管理

    [root@linux-node1 test]# git status On branch master nothing to commit, working directory clean

    建分支,开发新功能是不能在master分支上开发 [root@linux-node1 test]# git branch about #创建分支 [root@linux-node1 test]# git status On branch master nothing to commit, working directory clean [root@linux-node1 test]# git checkout about #切换分支 Switched to branch 'about' [root@linux-node1 test]# git status On branch about nothing to commit, working directory clean [root@linux-node1 test]# git log #创建的分支是在master分支当前的状态进行创建的。所以在about分支上也会有master的记录 commit e55a302e11d967fd25eac1cce8b6c7bed732019b Author: ************ Date: Fri Dec 8 22:49:57 2017 +0800

    pay modelue
    

    commit d83603a56b8926630d31b46898e4b6d69293d946 Author: ************ Date: Fri Dec 8 22:48:37 2017 +0800

    news
    

    commit c6bc04f90d4ef442e2c4d5bc788b21de239332da Author: ************ Date: Fri Dec 8 22:37:40 2017 +0800

    first commit
    

    [root@linux-node1 test]# git branch

    • about master [root@linux-node1 test]# touch about.html [root@linux-node1 test]# echo "about us" >> about.html [root@linux-node1 test]# git add . [root@linux-node1 test]# git commit -m "about" [about 08b200a] about 1 file changed, 1 insertion(+) create mode 100644 about.html [root@linux-node1 test]# git log [root@linux-node1 test]# git checkout master #切换到master分支 Switched to branch 'master' [root@linux-node1 test]# git log [root@linux-node1 test]# git checkout about #切换到about分支 [root@linux-node1 test]# echo "about2" > about2.html [root@linux-node1 test]# git add . [root@linux-node1 test]# git commit -m "about2" [root@linux-node1 test]# git log [root@linux-node1 test]# git checkout master [root@linux-node1 test]# git log [root@linux-node1 test]# git merged about #在master分支上合并about分支 [root@linux-node1 test]# git log [root@linux-node1 test]# git branch test #创建test分支 [root@linux-node1 test]# git checkout test [root@linux-node1 test]# touch "test" > test.html [root@linux-node1 test]# git add . [root@linux-node1 test]# git commit -m "test" [root@linux-node1 test]# git checkout master [root@linux-node1 test]# git branch --merged #查看已经合并的分支 [root@linux-node1 test]# git branch --no-merged #查看未合并的分支

    分支命令 git branch例出分支 git branch -v git branch --merged查看哪些分支被合并 git branch --no-merged查看哪些分支未被合并 git branch -d testling删除分支 git checkout切换分支 git merged融合分支

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )