简体   繁体   中英

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?

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

$ git clone https://user%40example.com:password@account.visualstudio.com/DefaultCollection/_git/Repository%20Name "Repository Name"

%40 is @ URL-escaped.

I found that if you update git to a newer version (I had version 1.7.1, after updating had 1.7.12.4) it started to prompt for username and password. Then you don't need to provide the username and or password in the clone statement.

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