首页 > 其他 > 详细

git jenkins 基本部署

时间:2019-10-23 21:45:21      阅读:93      评论:0      收藏:0      [点我收藏+]

                                                                git  jenkins  本地仓库基础

                                                                       技术分享图片

 

1.安装git

[root@gitlab ~]# yum install git -y   

2.配置git

[root@gitlab ~]# git config --global user.name "oldsjf"  
[root@gitlab ~]# git config --global user.email "oldsjf@foxmail.com"  
[root@gitlab ~]# git config --global color.ui true
3.实战一、git如何提交目录文件至至本地仓库?

[root@gitlab ~]# mkdir demo
[root@gitlab ~]# cd demo/
[root@gitlab demo]# git init    #初始化该目录为一个git的本地仓库
[root@gitlab demo]# echo "62-v1" > file.txt                #创建一个新文件
[root@gitlab demo]# git status
[root@gitlab demo]# git add file.txt                              #将文件添加至暂存区
[root@gitlab demo]# git status
[root@gitlab demo]# git commit -m "file-v1 commit"       #将暂存区内容提交至本地仓库
4.实战二、如何比对本地工作目录文件内容、暂存区文件内容、本地仓库文件内容之间的差异?

[root@gitlab demo]# git diff file.txt                       #本地与暂存对比
[root@gitlab demo]# git add .
[root@gitlab demo]# git diff file.txt
[root@gitlab demo]# git diff --cached file.txt            #暂存区与本地仓库对比
[root@gitlab demo]# git add .
[root@gitlab demo]# git commit -m "file-v3 commit"
[root@gitlab demo]# git diff --cached file.txt

5.实战三、提交内容至暂存区、或本地仓库,想回退怎么办?      回退功能!!!!危险性比较高

1.本地提交至暂存区向回退?  (当误操作本地目录的内容后,可以通过暂存区覆盖本地内容)

[root@gitlab demo]# git diff file.txt
        [root@gitlab demo]# > file.txt
        [root@gitlab demo]# cat file.txt
        [root@gitlab demo]# git checkout -- file.txt
        [root@gitlab demo]# cat file.txt

2.暂存区提交到本地仓库向回退怎么办?

[root@gitlab demo]# vim file.txt
        [root@gitlab demo]# git add .
        [root@gitlab demo]# git commit -m "file-v4 commit"          #提交了多次至本地仓库

        [root@gitlab demo]# git log --oneline                    #查看所有提交的历史记录
        [root@gitlab demo]# git reset --hard c926744            #回退到指定的CommitID上
        [root@gitlab demo]# cat file.txt

3.如果多次提交,多次回退?

        [root@gitlab demo]# git reflog     #查看所有的历史提交变更记录
        [root@gitlab demo]# git reset --hard 187e808

6.git分支是干什么的?

#1.基于master的位置点,创建了一个新的dev分支
    [root@gitlab demo]# git branch dev      创建新的支分支
    [root@gitlab demo]# git branch             查看处于哪条分支上

       dev
    * master

#2.dev分支操作如下:
    [root@gitlab demo]# git checkout dev        #切换分支
    [root@gitlab demo]# echo "oldxu" > file-2
    [root@gitlab demo]# echo "oldli" > file-3
    [root@gitlab demo]# git add .
    [root@gitlab demo]# git commit -m "dev-create new 2 file"    #dev更新了位置点
#3.回到master分支,更新master的位置点
    [root@gitlab demo]# git checkout master
    [root@gitlab demo]# echo "62-v5" >> file.txt
    [root@gitlab demo]# git add .
    [root@gitlab demo]# git commit -m "Master Update V5"

#4.切换dev分支,合并master

[root@gitlab demo]# git checkout dev
[root@gitlab demo]# git merge master   #站在dev分支合并master  -->安全
    --------------->测试检查ok
    
#5.切换回master主干分支,合并dev分支
    [root@gitlab demo]# git checkout master
    [root@gitlab demo]# git merge  dev    #站在master分支合并dev
    --------------->测试检查ok--->部署

7.git的tag标签是干什么?

    commitID          打上标签可以快速识别上线之后的版本方便认出,要回退的版本。
        123456        <----v1.0
        978765        <----v2.0
        978765        <----v2.1
        978765        <----v2.2

    1.如何打标签:
    [root@gitlab demo]#    git tag -a "v1.1" -m "全新升级1.1"
    2.如何查看标签
    [root@gitlab demo]# git tag -l
    [root@gitlab demo]# git show v1.1
    3.如何删除标签
    [root@gitlab demo]# git tag -d v1.1
    4.如何给指定的CommitID打上标签?
    [root@gitlab demo]# git tag  -a "v3.0" 187e808 -m "全新3,0版本升级"
    [root@gitlab demo]# git reset --hard v3.0        #方便后续的回退,或者记录当时的状态

 

git jenkins 基本部署

原文:https://www.cnblogs.com/oldsjf/p/11728853.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!