• 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
    

      

  • 相关阅读:
    Codeforces 468 B Two Sets
    POJ 3080 Blue Jeans
    Scan法求凸包
    线段树 区间更新 区间求和 板子
    拼图设计 课程作业三
    通讯录c#实现 课程作业二
    贷款计算器C#实现 课程作业一
    标准计算器C#实现 课程作业一
    ccf 行车路线
    hdu 4902 Nice boat
  • 原文地址:https://www.cnblogs.com/FENGXUUEILIN/p/9852720.html
Copyright © 2020-2023  润新知