连接到 TFS 或 Visual Studio Online 中的 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16835212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:17:33  来源:igfitidea点击:

Connect to git repository in TFS or Visual Studio Online

gittfsazure-devops

提问by Martijn

I have created a git repository at team foundation services, and I want to connect to it, but I don't know its URL and annoyingly can't find it.

我在团队基础服务处创建了一个 git 存储库,我想连接到它,但我不知道它的 URL 并且很烦人地找不到它。

I created my local repo and dit my initial commit

我创建了我的本地仓库并修改了我的初始提交

Now I wonder what remote I should set. I named my repo myproject.mysubproject on the foundation services website.

现在我想知道我应该设置什么遥控器。我在基金会服务网站上将我的 repo 命名为 myproject.mysubproject。

I tried https://mysubdomain.visualstudio.com/myproject.mysubprojectand https://mysubdomain.visualstudio.com/myproject.mysubproject.git, but for both, no cigar, and I'm pretty much out of ideas now. Does anyone know where I will be able to find the repo?

我试过https://mysubdomain.visualstudio.com/myproject.mysubprojecthttps://mysubdomain.visualstudio.com/myproject.mysubproject.git,但两者都没有雪茄,而且我现在几乎没有想法了。有谁知道我在哪里可以找到回购?

Edit: As a side note: I'm notworking from visual studio, nor do I want to for this project (but I will for other projects)

编辑:附带说明:我不是在 Visual Studio 工作,也不想为这个项目工作(但我会为其他项目工作)

回答by bryanmac

If you go to the web UI, under the "code" hub, if it's empty repo, the clone url will be there. If it's not empty there is an icon to the right (double paper icon) that will drop down with the clone url.

如果您转到 Web UI,在“代码”中心下,如果它是空的 repo,则克隆 url 将在那里。如果它不为空,则右侧有一个图标(双纸图标),该图标将与克隆 url 一起下拉。

The url will be in the form ...

网址将采用以下形式...

https://[youraccount].visualstudio.com/DefaultCollection/_git/[gitRepoName]

https://[youraccount].visualstudio.com/DefaultCollection/_git/[gitRepoName]

Also note that it's the same URL that's in your web browser if you browse to that projects code hub.

另请注意,如果您浏览到该项目代码中心,它与您的 Web 浏览器中的 URL 相同。

However, note in the last release, we added multiple repos per project. For the initial repo, the repo name matches the project so project name isn't required in the url. For additional repos, projectName may be required:

但是,请注意在上一个版本中,我们为每个项目添加了多个存储库。对于初始存储库,存储库名称与项目匹配,因此 url 中不需要项目名称。对于其他存储库,可能需要 projectName:

https://[youraccount].visualstudio.com/DefaultCollection/[projName]/_git/[gitRepoName]

https://[youraccount].visualstudio.com/DefaultCollection/[projName]/_git/[gitRepoName]

But once again, using the web UI is the easiest way to get the url.

但再一次,使用 Web UI 是获取 url 的最简单方法。

Once you have that url you can simply run git clone [url]

一旦你有了那个 url,你就可以简单地运行 git clone [url]

edit:

编辑:

For authentication, VSO recently added PAT tokens. You can use any username and the PAT token as the password. See more hereThis is not available for on-prem TFS yet.

对于身份验证,VSO 最近添加了 PAT 令牌。您可以使用任何用户名和 PAT 令牌作为密码。 在此处查看更多信息这不适用于本地 TFS。

You can also use Alternate Credentials: see more here

您还可以使用备用凭据: 在此处查看更多信息

回答by Jason Masters

This has been slightly tweaked in the newer versions of Visual Studio Online. Now go to your project, go to "Code", and then (assuming you've already set up a project) there will be a "Clone" button on the far right, hitting that will bring a little popup with the clone url (which is the git url). VSO Image

这在较新版本的 Visual Studio Online 中略有调整。现在转到您的项目,转到“代码”,然后(假设您已经设置了一个项目)在最右侧将有一个“克隆”按钮,点击该按钮会弹出一个带有克隆网址的小弹出窗口(这是 git 网址)。 VSO 图像