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版本
①编译安装git
[root@linux-node1 ~]# yum install -y epel-release
安装依赖包:
[root@linux-node1 ~]# yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
[root@linux-node1 ~]# wget https://github.com/git/git/archive/v2.7.4.zip
[root@linux-node1 ~]# yum install -y unzip
[root@linux-node1 ~]# unzip git-v2.7.4.zip
[root@linux-node1 ~]# cd git-2.7.
[root@linux-node1 git-2.7.]# make prefix=/usr/local/git all
[root@linux-node1 git-2.7.]# make prefix=/usr/local/git install
[root@linux-node1 git-2.7.]# rm -rf /usr/bin/git
[root@linux-node1 git-2.7.]# ln -s /usr/local/git/bin/git /usr/bin/git
[root@linux-node1 git-2.7.]# git --version
git version 2.7. ②初始化仓库
[root@linux-node1 ~]# mkdir test
[root@linux-node1 ~]# cd test
[root@linux-node1 test]# git init #将test目录初始化仓库
[root@linux-node1 test]# git config --global user.name"*****"
[root@linux-node1 test]# git config --global user.email *******@qq.com 四个区域:
远程仓库<-->本地仓库<-->暂存区域<-->工作目录 四种状态
Untracked、Unmodified、Modified、Staged
Untracked(工作目录)-->git add -->Staged(暂存区)-->git commit版本-->Unmodified(本地仓库)-->Edit file-->Modified-->Stage the file-->Staged ③常用命令:
git add 加入暂存
git status 查看状态
git status -s 状态概览
git diff 尚未暂存的文件
git diff --staged 暂存区文件
git commit 提交更新
git reset 回滚
git rm 从版本库中移除
git rm --cached README 从暂存区中移除
git mv 相当于mv git rm git add 三个命令 使用演示:
[root@linux-node1 test]# touch index.html ==>创建文件
[root@linux-node1 test]# vim index.html
[root@linux-node1 test]# git status ==>此时文件处于工作目录中
位于分支 master 初始提交 未跟踪的文件:
(使用 "git add <文件>..." 以包含要提交的内容) index.html 提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)
[root@linux-node1 test]# git add index.html ==>加入代码库
[root@linux-node1 test]# git status ==>此时文件处于暂存区
位于分支 master 初始提交 要提交的变更:
(使用 "git rm --cached <文件>..." 以取消暂存) 新文件: index.html [root@linux-node1 test]# git commit -m "first commit" ==>提交到本地仓库
[master(根提交) c6bc04f] first commit
file changed, insertions(+)
create mode index.html
[root@linux-node1 test]# git status
位于分支 master
无文件要提交,干净的工作区
[root@linux-node1 test]# git log
commit c6bc04f90d4ef442e2c4d5bc788b21de239332da ==>回滚需要的id
Author: ****** <******@qq.com>
Date: Fri Dec :: + first commit [root@linux-node1 test]# touch pay.html
[root@linux-node1 test]# vim pay.html
[root@linux-node1 test]# git add pay.html
[root@linux-node1 test]# git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: pay.html [root@linux-node1 test]# touch news.html
[root@linux-node1 test]# echo "" > news.html
[root@linux-node1 test]# git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: pay.html Untracked files:
(use "git add <file>..." to include in what will be committed) news.html [root@linux-node1 test]# git add news.html
[root@linux-node1 test]# git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: news.html
new file: pay.html [root@linux-node1 test]# git rm --cached pay.html #将pay.html从暂存区移除
rm 'pay.html'
[root@linux-node1 test]# git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: news.html Untracked files:
(use "git add <file>..." to include in what will be committed) pay.html [root@linux-node1 test]# git commit -m "news"
[master d83603a] news
file changed, insertion(+)
create mode news.html
[root@linux-node1 test]# git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed) pay.html nothing added to commit but untracked files present (use "git add" to track)
[root@linux-node1 test]# git log
commit d83603a56b8926630d31b46898e4b6d69293d946
Author:********
Date: Fri Dec :: + news commit c6bc04f90d4ef442e2c4d5bc788b21de239332da
Author: *****************
Date: Fri Dec :: + first commit
[root@linux-node1 test]# echo "" >> pay.html
[root@linux-node1 test]# git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed) pay.html nothing added to commit but untracked files present (use "git add" to track)
[root@linux-node1 test]# git add pay.html
[root@linux-node1 test]# git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: pay.html [root@linux-node1 test]# git commit -m "pay modelue"
[master e55a302] pay modelue
file changed, insertions(+)
create mode pay.html
[root@linux-node1 test]# git status
On branch master
nothing to commit, working directory clean
[root@linux-node1 test]# git log
commit e55a302e11d967fd25eac1cce8b6c7bed732019b
Author:******************
Date: Fri Dec :: + pay modelue commit d83603a56b8926630d31b46898e4b6d69293d946
Author: ******************
Date: Fri Dec :: + news commit c6bc04f90d4ef442e2c4d5bc788b21de239332da
Author: ******************
Date: Fri Dec :: + 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 :: + pay modelue commit d83603a56b8926630d31b46898e4b6d69293d946
Author: ************
Date: Fri Dec :: + news commit c6bc04f90d4ef442e2c4d5bc788b21de239332da
Author: ************
Date: Fri Dec :: + 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
file changed, insertion(+)
create mode 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融合分支
Gitlab+Jenkins学习之路(一)之Git基础的更多相关文章
- Gitlab+Jenkins学习之路(五)之git merge和git rebase的区别
命令行测试 [root@linux-node1 ~]# mkdir testing [root@linux-node1 ~]# [root@linux-node1 ~]# cd testing/ [r ...
- Gitlab+Jenkins学习之路(八)之发布maven项目及按版本发布
一.什么是Maven maven是一个项目管理和综合工具.Maven提供给开发人员构建一个完整的生命周期框架. 开发团队可以自动完成该项目的基础设施建设,Maven使用标准的目录结构和默认构建生命周期 ...
- Gitlab+Jenkins学习之路(十一)之Jenkins自动触发构建和发布
思路图: 一.下载gitlab plugin jenkins-->系统管理-->管理插件-->下载并安装gitlab plugin 二.配置gitlab认证 路径:Jenkins-- ...
- Gitlab+Jenkins学习之路(十三)之发布Java项目到tomcat
一.新建一台虚拟机安装tomcat ()安装JDK 官网下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downl ...
- Gitlab+Jenkins学习之路(十四)之自动化脚本部署实践
目录 一.环境说明和准备 1.环境说明 2.服务器准备工作 二.发布脚本编写 1.自动化部署流程设计 2.自动化部署脚本编写 三.发布测试 1.开发机和github添加ssh信任 2.克隆项目到开发机 ...
- Gitlab+Jenkins学习之路(三)之gitlab权限管理--issue管理
1.创建Group,User,Project 创建一个组,组名为java Group path http://192.168.56.11/java Visibility Level: #为权限级别,一 ...
- Gitlab+Jenkins学习之路(四)之gitlab备份和恢复
gitlab的备份和恢复 (1)创建备份目录,并授权 [root@linux-node1 ~]# mkdir /data/backups/gitlab -p [root@linux-node1 ~]# ...
- Gitlab+Jenkins学习之路(六)之Jenkins部署、升级和备份
一.什么是持续集成? (1)Continuous integration(CI) 持续集成是一种软件开发实践,即团队开发成员经常集成他们的工作,通常每个成员至少集成一次,也就意味着每天可能会发生多次集 ...
- Gitlab+Jenkins学习之路(七)之发布PHP项目
使用git+jenkins实现持续集成 Step1:构建一个自由风格的php-deploy Step2:Gernal配置,丢弃旧的构建,防止jenkins构建较多之后变臃肿 Step3:源码管理:这里 ...
随机推荐
- (1)StringBuilder类和StringBuffer类 (2)日期相关的类 (3)集合框架 (4)List集合
1.StringBuilder类和StringBuffer类(查手册会用即可)1.1 基本概念 由于String类描述的字符串内容无法更改,若程序中出现大量类似的字符串时需要申请独立的内存空间单独保存 ...
- (1)访问控制 (2)final关键字 (3)对象创建的过程 (4)多态
1.访问控制(笔试题)1.1 常用的访问控制符 public - 公有的 protected - 保护的 啥也不写 - 默认的 private - 私有的 1.2 访问控制符的比较 访问控制符 访问权 ...
- chrome开发者工具那点事
Elements:查找网页源代码HTML中的任一元素,手动修改任一元素的属性和样式且能实时在浏览器里面得到反馈. Console:记录开发者开发过程中的日志信息,且可以作为与JS进行交互的命令行She ...
- [WHY]Hello, Worktile~
本来是水水的去听一听云计算大会,感受一下氛围的, 万万没想到,竟然意外的參观了Worktile,这也成了北京之旅最值得纪念的记忆. 先是路上看到QQ有个好友请求,备注是Worktile市场的小泽. 从 ...
- 浏览器地址栏运行JavaScript代码
这个很多人应该还是知道的,在浏览器地址栏可以直接运行JavaScript代码,做法是以javascript:开头后跟要执行的语句.比如: javascript:alert('hello from ad ...
- OSM
一.OSM是什么 开放街道图(OpenStreetMap,简称OSM)是一个网上地图协作计划,目标是创造一个内容自由且能让所有人编辑的世界地图(wiki:http://wiki.openstreetm ...
- [SDOI2010]Hide and Seek
题目 非常显然就是求一下距离每一个点曼哈顿距离最近的点和最远的点就好了 最远点非常好算,我们建完\(kd-tree\)之后直接暴力就好了 找最近点的时候会有这样一个问题,就是自己找到了自己 所以我们需 ...
- 【CF917D】Stranger Trees
题目 看题解的时候才突然发现\(zky\)讲过这道题啊,我现在怕不是一个老年人了 众所周知矩阵树求得是这个 \[\sum_{T}\prod_{e\in T}w_e\] 而我们现在的这个问题有些鬼畜了, ...
- 【洛谷】【动态规划(多维)】P1006 传纸条
[题目描述:] 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸 ...
- LeetCode559. Maximum Depth of N-ary Tree
第一次写出了具有迭代和递归的函数,还是有点收获的,虽然题目比较简答 当要对某些对象重复使用时,考虑循环,也就是迭代 当函数可以简化一个重复的操作时,考虑递归,而且就当下一次使用这和函数的结果已经有啦, ...