zoukankan      html  css  js  c++  java
  • Git分支管理[三]

    标签(linux): git

    笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流

    git分支管理命令

    git branch    #创建分支
    git branch -v    #详细显示创建过程
    git branch -merged    #查看已融合过的分支
    git branch --no-merged    #查看哪些分支没有被融合
    git branch -d testing    #删除分支
    git checkout    #切换分支
    git merge    #融合分支
    git log
    git stash    #做一个暂存区
    git tag        #打标记
    

    创建一个分支

    [root@git test]# git branch about
    [root@git test]# git branch 
      about
    * master
    

    查看状态可发现还在master

    [root@git test]# git status 
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
    	news.html
    	pay.html
    
    nothing added to commit but untracked files present (use "git add" to track)
    

    切换到about分支

    [root@git test]# git checkout about 
    Switched to branch 'about'
    [root@git test]# git status 
    On branch about
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
    	news.html
    	pay.html
    
    nothing added to commit but untracked files present (use "git add" to track)
    

    验证分支是否创建成功

    [root@git test]# echo "about us" > about.html
    [root@git test]# git add .
    [root@git test]# git commit -m "about"
    [about 2390a21] about
     3 files changed, 3 insertions(+)
     create mode 100644 about.html
     create mode 100644 news.html
     create mode 100644 pay.html
    [root@git test]# git log
    commit 2390a21f03a22ab4c9ae81de0736e1e9bbcdbebf
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Fri Aug 18 00:16:36 2017 +0800
    
        about
    
    commit 145b100cd0e07a9e59e15cf71aad3338ed8a57a6
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Thu Aug 17 23:42:32 2017 +0800
    
        index.html
    

    切回到master分支查看

    [root@git test]# git log
    commit 2390a21f03a22ab4c9ae81de0736e1e9bbcdbebf
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Fri Aug 18 00:16:36 2017 +0800
    
        about
    
    commit 145b100cd0e07a9e59e15cf71aad3338ed8a57a6
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Thu Aug 17 23:42:32 2017 +0800
    
        index.html
    [root@git test]# git checkout master 
    Switched to branch 'master'
    [root@git test]# git log 
    commit 1cf6888d97b0a361a3daed01a06c67936bc4f241
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Thu Aug 17 23:49:27 2017 +0800
    
        first index:v2
    
    commit 145b100cd0e07a9e59e15cf71aad3338ed8a57a6
    Author: chentiangang <chentiangang@yoho8.com>
    Date:   Thu Aug 17 23:42:32 2017 +0800
    
        index.html
    

    融合分支

    * 注意:如果是master想跟about融合,需要先切换到master然后执行命令
    [root@git test]# git merge about 
    Merge branch 'about'
    
    # Please enter a commit message to explain why this merge is necessary,
    # especially if it merges an updated upstream into a topic branch.
    #
    # Lines starting with '#' will be ignored, and an empty message aborts
    # the commit.
                                                                                                                                               
    ~                                                                                                                                                 
    ".git/MERGE_MSG" 7L, 248C written
    Merge made by the 'recursive' strategy.
     about.html  | 1 +
     about2.html | 1 +
     news.html   | 1 +
     pay.html    | 1 +
     4 files changed, 4 insertions(+)
     create mode 100644 about.html
     create mode 100644 about2.html
     create mode 100644 news.html
     create mode 100644 pay.html
    

  • 相关阅读:
    linux的redis的安装和使用
    在linux上安装Mysql和使用
    linux的python3的安装
    linux的优化和命令
    LeetCode 542. 01 Matrix
    Qt keyPressEvent
    QOpenGLTexture 两个纹理叠加
    Qt5.6.0+OpenGL 纹理贴图首战告捷
    更改Qt Application为 Qt Console Application
    Learning part-based templates from large collections of 3D shapse CorrsTmplt Kim 代码调试
  • 原文地址:https://www.cnblogs.com/Csir/p/7382357.html
Copyright © 2011-2022 走看看