简体   繁体   中英

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? I know how to do it in command but not sure how to di it using new git in Visual Studio 2019.

在此处输入图像描述

All I can do is to clone the master first and choose the specific branch from there.

While using Git, its advisable to use a CMD or PowerShell instance. 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).

If you want to get it done through the UI:

  1. You first need to go to 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. That's it. 在此处输入图像描述

If you click on different branches, the URLs will be different. For example now I selected constraints-2-0 and as you can see the URL at the top has changed. 在此处输入图像描述

There seems to be only one route to get a branch via VS. It cannot be done directly but there is a simple path.

  1. Get the address of the main branch from the repo. Forget about branches at this point.

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

  1. Tell VS that you want to clone an existing repo.

通过 VS 克隆

  1. Give VS the git repo address - it's in the paste buffer so just paste it into the repo location field. Set repo destination. Start clone operation.

设置 VS 回购信息

  1. Observe VS complete operation. (If credentials are already correct.)

VS克隆master成功。

  1. Switch to desired branch - in this example it's dev.

切换到所需的回购。

That's it. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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