• git branch 相关操作总结 新建分支 删除分支 切换分支 查看分支


    1. 查看分支

      (1) 查看本地分支  git branch 列出本地已经存在的分支,并且在当前分支的前面加*号标记,例如:
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master

      (2) 查看远程分支  git branch -r 例如:
      localhost:website admin$ git branch -r
        origin/branch_dev_2_1_0
        origin/branch_dev_2_1_0_cover
        origin/branch_dev_2_1_0_metrics
        origin/branch_dev_2_1_0_php7
        origin/master

      (3) 查看所有分支  git branch -a 例如:
      localhost:website admin$ git branch -a
      * branch_dev_2_1_0
        master
        origin/branch_dev_2_1_0
        origin/branch_dev_2_1_0_cover
        origin/branch_dev_2_1_0_metrics
        origin/branch_dev_2_1_0_php7
        origin/master
    2. 新建分支

      (1)新建分支但不切换到该分支  git branch 分支名,例如:
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master
      localhost:website admin$ git branch new_branch
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master
        new_branch
      可以看出,虽然新建了本地分支 new_branch 但是当前分支并没有切换(带*号为当前分支)

      (2) 新建并切换到该分支  git checkout -b 分支名,例如:
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master
      localhost:website admin$ git checkout -b new_branch
      Switched to a new branch 'new_branch'
      localhost:website admin$ git branch
        branch_dev_2_1_0
        master
      * new_branch
      新建本地分支 new_branch 的同时将当前分支切换为 new_branch (带*号为当前分支)

    3. 分支切换

      git checkout 分支名,例如:
      localhost:website admin$ git branch
        branch_dev_2_1_0
        master
      * new_branch
      localhost:website admin$ git checkout master
      Switched to branch 'master'
      localhost:website admin$ git branch
        branch_dev_2_1_0
      * master
        new_branch
      可以看出,原来的分支为 new_branch ,执行完 git checkout master 后,将分支切换到 master(带*号为当前分支)

    4. 删除本地分支

      git branch -d 分支名,例如:
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master
        new_branch
      localhost:website admin$ git branch -d new_branch
      Deleted branch new_branch (was e6d6ae0).
      localhost:website admin$ git branch
      * branch_dev_2_1_0
        master
      可以看出,原来总共有3个分支,删除 new_branch后变成了两个分支
  • 相关阅读:
    HTML 简介
    Composer 安装与使用
    给手绘图着色(添加颜色或色彩):CVPR2020论文点评
    图像分类:CVPR2020论文解读
    CVPR2020论文解读:OCR场景文本识别
    CVPR2020论文解读:手绘草图卷积网络语义分割
    汽车芯片综述
    CVPR2020论文解析:视觉算法加速
    CVPR2020无人驾驶论文摘要
    CVPR2020论文解析:视频语义检索
  • 原文地址:https://www.cnblogs.com/smallrookie/p/6641078.html
Copyright © 2020-2023  润新知