简体   繁体   English

如何从新的 git Visual Studio 2019 克隆特定分支(不是从命令)?

[英]How to clone a specific branch from new git Visual Studio 2019 (not from command)?

How to clone a specific branch from git Visual Studio 2019?如何从 git Visual Studio 2019 克隆特定分支? I know how to do it in command but not sure how to di it using new git in Visual Studio 2019.我知道如何在命令中执行此操作,但不确定如何在 Visual Studio 2019 中使用新的 git 进行操作。

在此处输入图像描述

All I can do is to clone the master first and choose the specific branch from there.我所能做的就是先克隆master,然后从那里选择特定的分支。

While using Git, its advisable to use a CMD or PowerShell instance.在使用 Git 时,建议使用 CMD 或 PowerShell 实例。 Can you try:你能试一下吗:

git clone -b branch_name --single-branch 'repo_url'

branch_name is the name of your branch, and repo_url is the link of your remote repository (repository location). branch_name是您的分支的名称, repo_url是您的远程存储库的链接(存储库位置)。

If you want to get it done through the UI:如果你想通过 UI 完成它:

  1. You first need to go to Github你首先需要 go 到 Github
  2. From the branches dropdown click on the branch you need.从分支下拉列表中单击您需要的分支。 You can view the dropdown here:您可以在此处查看下拉列表: 在此处输入图像描述
  3. Then copy the Github URL (Copy from the address bar) and paste it in VS studio.然后复制 Github URL(从地址栏复制)并粘贴到 VS studio 中。 That's it.而已。 在此处输入图像描述

If you click on different branches, the URLs will be different.如果您单击不同的分支,则 URL 会有所不同。 For example now I selected constraints-2-0 and as you can see the URL at the top has changed.例如,现在我选择了constraints-2-0 ,你可以看到顶部的 URL 发生了变化。 在此处输入图像描述

There seems to be only one route to get a branch via VS.似乎只有一种途径可以通过 VS 获得分支。 It cannot be done directly but there is a simple path.它不能直接完成,但有一个简单的路径。

  1. Get the address of the main branch from the repo.从 repo 中获取主分支的地址。 Forget about branches at this point.在这一点上忘记分支。

通过克隆选项获取主地址。

  1. Tell VS that you want to clone an existing repo.告诉 VS 你要克隆一个现有的仓库。

通过 VS 克隆

  1. Give VS the git repo address - it's in the paste buffer so just paste it into the repo location field.给 VS git 回购地址 - 它在粘贴缓冲区中,所以只需将其粘贴到回购位置字段中。 Set repo destination.设置回购目的地。 Start clone operation.开始克隆操作。

设置 VS 回购信息

  1. Observe VS complete operation.观察VS完成操作。 (If credentials are already correct.) (如果凭据已经正确。)

VS克隆master成功。

  1. Switch to desired branch - in this example it's dev.切换到所需的分支 - 在这个例子中它是 dev。

切换到所需的回购。

That's it.而已。 Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM