Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly clone a visualstudio.com TFS Git repository from a command line?

I am trying to use command line git to clone a TFS-based Git repository located at visualstudio.com. The actual address of the repo is

https://kalamon.visualstudio.com/DefaultCollection/_git/gitp

I have enabled "alternate credentials" in my profile, I have also set a username alias that does not contain a @ (because this messes up git clone). Yet, all attempts to clone the repo, or pull it or whatever else results in this error:

Cloning into 'gitp'...
fatal: https://kalamon.visualstudio.com/DefaultCollection/_git/gitp/info/refs not valid: is this a git repository?

I tried this with a different Git repository on the same account with the same result.

I have tried all kind of things - like putting <username>:<password>@ after https:// or using _netrc, but nothing works. Same error happens no matter what I try. I am not prompted for credentials on the command line.

When I use curl to get https://kalamon.visualstudio.com/DefaultCollection/_git/gitp/info/refs and provide basic authentication, I get them without an issue.

Cloning from VS2013 UI works fine. However, I really need to be able to do this from the command line, because I need to make cloning work from scripted environment.

Does anybody have any ide what could be wrong?

UPDATE

I did some digging, and it turns out that only my account is affected. When I tried on a different account on visualstudio.com, things work just fine.

I also did some tracing, and it turned out that on my account the response from Git server is somewhat strange (I would say incorrect) - instead of responding with 401 error code ("unauthenticated"), the server responds with 302 ("redirect") - redirecting to login page. On properly working account, the server properly responds with a 401 code and things work fine. It is as if on my account the "alternate credentials" setting is not set up and the server does not allow basic authentication at all.

Have I just found a problem with visualstudio.com?

like image 453
user1537794 Avatar asked Nov 25 '14 21:11

user1537794


People also ask

How do I clone a Git repository in Visual Studio using terminal?

You can search for and clone a repository from GitHub using the Git: Clone command in the Command Palette (Ctrl+Shift+P) or by using the Clone Repository button in the Source Control view (available when you have no folder open).

How do I clone a TFS repository in Visual Studio?

On the start window, select Clone a repository. In the Browse a repository section, select Azure DevOps. If you see a sign-in window, sign in to your account. In the Connect to a Project dialog box, choose the repo that you want to connect to, and then select Clone.


1 Answers

I just tried on my VSO account using Git Bash and works fine.

$ git clone https://user%40example.com:[email protected]/DefaultCollection/_git/Repository%20Name "Repository Name"

%40 is @ URL-escaped.

like image 117
Giulio Vian Avatar answered Oct 01 '22 07:10

Giulio Vian