2

I get this error when trying to clone a repository from Azure Devops in Visual Studio 2019 :

TF401019: The Git repository with name or identifier X does not exist or you do not have permissions for the operation you are attempting.
Error encountered while cloning the remote repository: Git failed with a fatal error.

I'm using two accounts :

[email protected] is my main account in visual studio, it has access to my repo, but no rights. [email protected] is another account setup in visual studio, it has full access to my repo.

When I try to clone the repo, I get the error above. In Azure Devops, I noticed that a personal access token is created in my first account and not in my second account, so I'm assuming that it's trying to connect with the wrong account. I never get asked for credentials from Visual studio, even when I delete the credentials from the Windows Credentials Manager and clear the cache from IE and Edge.

Is there a way to specify under which account to clone an Azure Devops repository in Visual Studio 2019?

---- Update

When I'm cloning, I'm logged in with account #2 in visual studio and listing repos under dev.azure.com

enter image description here

But I get this error :

Remote: TF401019: The Git repository with name or identifier X does not exist or you do not have permissions for the operation you are attempting.
Error encountered while cloning the remote repository: Git failed with a fatal error.
repository 'https://dev.azure.com/X' not found

And then, in Azure Devops, with account #1, a PAT is created enter image description here

The PAT gets stored in the Windows Credentials Manager (I delete it for each try) enter image description here

1
  • Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue? Commented May 13, 2020 at 9:52

2 Answers 2

2

Is there a way to specify under which account to clone an Azure Devops repository in Visual Studio 2019?

Sorry for any inconvenience.

This behavior is by designed. We could not specify another account to clone an Azure Devops repository in Visual Studio.

When we connect the repo from the Visual Studio, it prompts for login account instead of entering authentication information:

enter image description here

If we want to specify another account to clone the repo, we need to keep two more credentials in Visual Studio. When we are in the process of synchronizing VS with Azure devops, VS cannot intelligently choose which certificate to use for authentication, otherwise we must manually select the certificate each time we synchronize the code.

On the other side, we could not specify another account in the login account, which may involve the issue of overrun (low-privilege accounts use high-privilege accounts).

That the reason why visual studio lets us use a login account as authentication.

If you want to use another account to clone the code from repo, you could try to use the command line and PAT, like:

git clone https://<PAT>@dev.azure.com/<OrganizationName>/YourProject/_git/..

Username nor password should not be required as the PAT should suffice.

Hope this helps.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer, the PAT approach in the URL does work, so it's a nice workaround. As for the "Connect to a project" window, I do login with the right account, it's listing the right repos, but when I try to clone, it's cloning with the wrong account. Is that the behavior you are describing?
I know it's cloning with the wrong account because, as I stated in the post, I get an error in visual studio and a PAT is created under the wrong account each time I clone. I will update the post with screenshots to detail further.
@Phil-R, Sorry for my late reply, I just got out of other threads. According to your reply, it seems the issue comes from the Visual Studio, if you can clone with the PAT in the command line. So, we could try to clean the cache for Visual Studio, like using devenv /resetuserdata command in the VS Developer Command Prompt as an Administrator. Or Clear the config from the following path: `C:\users\<user>\AppData\Roaming\Microsoft\VisualStudio\15.0_????\Team Explorer`, even we can test it on other PC.
0

I'm assuming Windows?
VS may be falling back to the wrong identity, I don't think there is a way to force VS to use certain account over the other. I suggest you clone from the command line. VS has its own Git client so it handles identities outside git credential manager which will ask for credentials if it cannot find one within Windows credential manager.

MS support would suggest the following though not sure it will work:

Try signing out and forget your accounts. Remove caches. VS Identities are cached in the following paths for windows.

C:\Users\{user}\AppData\Local\.IdentityService
C:\Users\{user}\AppData\Local\Microsoft\Team Foundation\{each version}\Cache
C:\Users\{user}\AppData\Local\Microsoft\Team Foundation\{each version}\Cache
C:\Users\{user}\AppData\Local\Microsoft\VisualStudio Services\{each version}\Cache
C:\Users\{user}\AppData\Local\GitCredentialManager\tenant.cache

Also clean your Windows credential manager entries that begin with git:*.

After following these steps I would expect git to ask for credentials if you clone from the command line.

1 Comment

Thanks, it does ask for credentials after I clean these caches, but even though I log with the right account, the clone still creates a PAT for the wrong account

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.