git如何从远程非master分支更新到本地对应分支

自己实例

正确步骤

如果本地有分支,那就删除本地分支

删除本地分支::git branch -d 2018_4_18_second

切换分支: git checkout master

将远程分支 上的东西拉下来: git checkout -b 2018_4_18_second origin/2018_4_18_second

# 列出所有本地分支$ git branch
# 列出所有远程分支$ git branch -r
# 列出所有本地分支和远程分支$ git branch -a
# 新建一个分支,并切换到该分支$ git checkout -b [branch]

拉文件下来的话

git pull https://github.com/fry404006308/m_Orchestrate.git 2018_4_18_second

或者试试

git pull

善于使用帮助命令,特别好用

从帮助命令知道怎么弄,超级快

git help pull

然后你会看到这样的示例用法:

 EXAMPLES
Update the remote-tracking branches for the repository you cloned from, then merge one of them into your current branch: $ git pull
$ git pull origin
Normally the branch merged in is the HEAD of the remote repository, but the choice is determined by the branch.<name>.remote and branch.<name>.merge options; see git-config() for details. Merge into the current branch the remote branch next: $ git pull origin next
This leaves a copy of next temporarily in FETCH_HEAD, but does not update any remote-tracking branches. Using remote-tracking branches, the same can be done by invoking fetch and merge: $ git fetch origin
$ git merge origin/next
If you tried a pull which resulted in complex conflicts and would want to start over, you can recover with git reset.

所以就知道怎么弄了

将远程git仓库里的指定分支拉取到本地(本地不存在的分支)

当我想从远程仓库里拉取一条本地不存在的分支时:

git checkout -b 本地分支名 origin/远程分支名

这个将会自动创建一个新的本地分支,并与指定的远程分支关联起来。

例如远程仓库里有个分支dev2,我本地没有该分支,我要把dev2拉到我本地:

若成功,将会在本地创建新分支dev2,并自动切到dev2上。

如果出现提示:

fatal: Cannot update paths and switch to branch 'dev2' at the same time.
Did you intend to checkout 'origin/dev2' which can not be resolved as commit?

表示拉取不成功。我们需要先执行

git fetch

然后再执行

git checkout -b 本地分支名 origin/远程分支名

即可。

git checkout -b 2018_4_18_second

忘记 pull up了 远程建立分支后,要pull up更新一下本地,就可以显示出来了,新手,弄了几个小时,才弄出来。。

git pull之后,才显示远程分支

别人实例

git一般有很多分支,我们clone到本地的时候一般都是master分支,那么如何切换到其他分支呢?主要命令如下:

1. 查看远程分支

$ git branch -a 
我在mxnet根目录下运行以上命令:

~/mxnet$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/nnvm
remotes/origin/piiswrong-patch-1
remotes/origin/v0.9rc1

可以看到,我们现在在master分支下

2. 查看本地分支

~/mxnet$ git branch
* master

3. 切换分支

$ git checkout -b v0.9rc1 origin/v0.9rc1
Branch v0.9rc1 set up to track remote branch v0.9rc1 from origin.
Switched to a new branch 'v0.9rc1' #已经切换到v0.9rc1分支了
$ git branch
master
* v0.9rc1 #切换回master分支
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
 

git如何从远程非master分支更新到本地对应分支的更多相关文章

  1. git拉取远程分支到本地分支或者创建本地新分支

    git fetch origin branchname:branchname 可以把远程某各分支拉去到本地的branchname下,如果没有branchname,则会在本地新建branchname g ...

  2. git使用 从远程库克隆和更新到本地

    从远程库克隆到本地. git clone git@github.com:kingbook/Framework.git 或 git clone http://github.com/kingBook/Fr ...

  3. git删除远程分支和本地分支以及更改本地和分支名字

    问题描述: 当我们集体进行项目时,将自定义分支push到主分支master之后,如何删除远程的自定义分支呢 问题解决: (1)使用命令git branch -a 查看所有分支 注: 其中,remote ...

  4. 将远程UI分支克隆到本地UI分支

    git checkout -b UI git remote add origin <url> git fetch origin git branch --track UI origin/U ...

  5. git clone新项目后如何拉取分支代码到本地

    1.git clone git@git.n.xxx.com:xxx/xxx.git 2.git fetch origin dev    命令来把远程dev分支拉到本地 3.checkout -b de ...

  6. git clone新项目后如何拉取其他分支代码到本地

    1.git clone git@git.n.xxx.com:xxx/xxx.git 2.git fetch origin dev 命令来把远程dev分支拉到本地 - - 解读:git fetch命令用 ...

  7. git 操作 :从远程仓库gitLab上拉取指定分支到本地仓库;git如何利用分支进行多人开发 ;多人合作代码提交实践

    例如:将gitLab 上的dev分支拉取到本地 git checkout -b dev origin/dev 在本地创建分支dev并切换到该分支 git pull origin dev 就可以把git ...

  8. Git拉取远程仓库代码并更新本地仓库

    1.git pull:获取最新代码到本地,并自动合并到当前分支 //查询当前远程分支 $ git remote -v //直接拉取并合并最新代码 $ git pull origin master [示 ...

  9. git与eclipse集成之创建及切换个人本地分支

    创建个人本地特性分支,并进行编码 弹出选择分支的窗口,选择要切换的个人特性分支(备注:根据远程个人特性分支创建本地个人特性分支) 点击OK,Branch name:分支名称与远程分支名称相同,不需要修 ...

随机推荐

  1. Multi-Byte Character Set & Unicode Character Set

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/49592361 编程时遇到BUG:err ...

  2. 不安全的直接对象引用:你的 ASP.NET 应用数据是否安全?

    介绍 作为一个在X94的航空工程师,你的老板要求你从2号楼的工程图中检索出一个特定的专利.不幸的是,进入大楼需要你出示你具有进入大楼的资格的证明,然后你迅速地以徽章的形式出示给了保安.到了十三楼,进入 ...

  3. [Transducer] Make an Into Helper to Remove Boilerplate and Simplify our Transduce API

    Our transduce function is powerful but requires a lot of boilerplate. It would be nice if we had a w ...

  4. jquery开发之代码风格

    1,链式操作风格. (1) 对于同一个对象不超过三个操作的.可直接写成一行.代码例如以下: $("li").show().unbind("click"); (2 ...

  5. SDUTOJ 2776 小P的故事——奇妙的分组

    #include<iostream> #include<math.h> #include<memory.h> using namespace std; int dp ...

  6. SPOJ1812: LCS2 - Longest Common Substring II & BZOJ2946: [Poi2000]公共串

    [传送门:SPOJ1811&BZOJ2946] 简要题意: 给出若干个字符串,求出这些字符串的最长公共子串 题解: 后缀自动机 这两道题的区别只是在于一道给出了字符串个数,一个没给,不过也差不 ...

  7. CAP定理在分布式系统设计中的最新应用

    本文翻译自国外InfoQ和计算机杂志上一篇2012年旧文,本文就有关数据同步进行了讨论,特别关注业务事务的不变性与一致性如何在分布式系统中巧妙保证,探讨了长时间运行的事务的补偿机制.这些对分布式系统设 ...

  8. Error creating bean with name 'testController': Injection of resource dependencies failed;

    启动ssm项目报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't ...

  9. PostgreSQL Replication之第九章 与pgpool一起工作(5)

    9.5 检查复制 如果所有的节点都处于开机并运行的状态.我们就可以在集群上运行我们的第一个操作了.在我们的例子中,我们将简单地连接到pgpool并创建一个新的数据库.createdb 是一个命令行工具 ...

  10. PostgreSQL Replication之第三章 理解即时恢复(4)

    3.4 重放事务日志 一旦我们创建了一个我们自己的初始基础备份,我们可以收集数据库创建的XLOG.当时间到时,我们可以使用所有这些XLOG 文件并执行我们所期望的恢复进程.这就像本节描述的一样工作. ...