zoukankan      html  css  js  c++  java
  • git拉取远程分支到本地

    查看远程分支:
    git branch -a
    查看本地分支:
    git branch

    场景:
    假如现在远程分支有一个:demo
    我们本地没有;

    ·
    ·
    1.查看远程分支有哪些:
    git branch -a
    2.然后切换到这个分支:
    git checkout remotes/origin/demo

    出来了这么一段话:

    $ git checkout remotes/origin/demo
    Note: checking out 'remotes/origin/demo'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:

    git checkout -b <new-branch-name>

    HEAD is now at 1ad17a6... 演示demo8月12日提交


    3.就按照它说的执行:
    git checkout -b a
    然后就可以了。
    ·
    ·
    但是,如果执行git pull 会报错,是因为没有和远程分支建立联系(没有跟踪信息)
    解决方法:
    和远程分支a建立联系:
    git branch --set-upstream-to=origin/demo
    然后就可以了
    git pull

  • 相关阅读:
    [转]IDEA 新建 JSP 项目时
    [转] AForge.NET 图像处理类
    [转] 端口被占用的处理
    [极客大挑战 2019]PHP
    今天鸽了
    [ZJCTF 2019]NiZhuanSiWei
    [极客大挑战 2019]Secret File
    [SUCTF 2019]Pythonginx
    [CISCN2019 华北赛区 Day1 Web2]ikun
    [极客大挑战 2019]EasySQL
  • 原文地址:https://www.cnblogs.com/longailong/p/11512112.html
Copyright © 2011-2022 走看看