我如何获取远程分支?

时间:2016-02-11 13:37:09

标签: git gitlab

我意外删除了我的git文件夹。我在远程分支机构库工作。 我如何将我的远程分支拉到我的本地?

3 个答案:

答案 0 :(得分:3)

如果你还有git repo:

只做

git fetch origin

接着是。

git checkout -b <branch> origin/branch

如果您已完全删除了git存储库 然后重新放行存储库:

git clone <repository-address>

然后,按照上面的步骤获取其他分支,如果他们没有自动拉入。

答案 1 :(得分:0)

  

我意外删除了我的git文件夹。我在远程分支机构库工作。我如何将我的远程分支拉到我的本地?

怎么做?

  1. 再次克隆回购
  2. 检查所需的分支

    # Clone the repo
    git clone <url>
    
    # Checkout the desired branch
    git checkout <branch name>
    
  3. 如果您仍然拥有.git文件夹并且未将其删除,请阅读如何将代码恢复到此处:
    How to move HEAD back to a previous location? (Detached head)

答案 2 :(得分:0)

git checkout -b branch_name
git pull URL branch_name