Connect to git repository in TFS or Visual Studio

2019-01-22 18:26发布

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.

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.

I tried https://mysubdomain.visualstudio.com/myproject.mysubproject and 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?

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

2条回答
虎瘦雄心在
2楼-- · 2019-01-22 19:05

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

查看更多
乱世女痞
3楼-- · 2019-01-22 19:06

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.

The url will be in the form ...

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.

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:

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

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

Once you have that url you can simply run 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 here This is not available for on-prem TFS yet.

You can also use Alternate Credentials: see more here

查看更多
登录 后发表回答