zoukankan      html  css  js  c++  java
  • git从已有分支拉取新分支

    在项目开发和维护中,经常需要从一个已有的分支拉取出一个新的分支,每次都记不住,所以现在将其记录下来,方便以后查看:

    1:需要切换到被拉取的分支,并且拉取项目,命令如下:

    $git checkout master  
    
    $git pull

    2:接着创建一个新分支,并且切换到新的分支:

    $git checkout -b newbranch

    Switched to a new branch 'dev'

     上述命令是一步完成创建和切换,也可以先创建,在切换:

    $git branch newbranch
    
    $git checkout newbranch
    

    3:把本地分支push到远端:

    $git push origin newbranch
    

    4:拉取远端分支

    $git pull
    
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
    git pull <remote> <branch>
    
    If you wish to set tracking information for this branch you can do so with:
    
    git branch --set-upstream-to=origin/<branch> newbranch
    

     5:这说明,当前分支还没有和本地分支进行关联,下面进行关联

    git branch --set-upstream-to=origin/<branch> newbranch
    

     6:再次拉取,完成任务。

    $git pull
    

      

  • 相关阅读:
    typescript 箭头表达式
    typescript 参数类型
    ts介绍
    pm2
    koa2安装
    linux 搭建ftp
    CENTOS6.5 安装 mysql5.6 以及搭建双主
    bzoj 3043 (差分序列运用)
    poj 3277 City Horizon
    NOI2015 程序自动分析
  • 原文地址:https://www.cnblogs.com/FENGXUUEILIN/p/9852720.html
Copyright © 2011-2022 走看看