git从已有分支拉取新分支

在项目开发和维护中,常常须要从一个已有的分支拉取出一个新的分支,每次都记不住,因此如今将其记录下来,方便之后查看:html

1:须要切换到被拉取的分支,而且拉取项目,命令以下:git

$git checkout master  

$git pull

2:接着建立一个新分支,而且切换到新的分支:sql

$git checkout -b newbranch

Switched to a new branch 'dev'

 上述命令是一步完成建立和切换,也能够先建立,在切换:this

$git branch newbranch

$git checkout newbranch

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

$git push origin newbranch

4:拉取远端分支orm

$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:这说明,当前分支尚未和本地分支进行关联,下面进行关联htm

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

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

$git pull
相关文章
相关标签/搜索