git clone: Authentication failed for <URL> git clone: Authentication failed for <URL> windows windows

git clone: Authentication failed for <URL>


I was facing same error when I was trying to clone a repository on a brand new machine. I'm using Git bash as my Git client. When I ran Git's command to clone a repository it was not prompting me for user id and password which will be used for authentication. It was a fresh machine where not a single credential was cached by Windows credential manager.

As a last resort, I manually added my credentials in credentials manager.

Go to > Control Panel > Click User Accounts > Click Credential Manager > Click Windows Credentials

Now, click the Add a Windows credential (highlighted in yellow) in Windows Credentials section as shown in the screenshot below:

enter image description here

Now, enter the details as shown in the form below and click OK:

enter image description here

I had put the details as below:

Internet or network address: <gitRepoServerNameOrIPAddress>User Name: MyCompanysDomainName\MyUserNamePassword: MyPassword

Next time you run any Git command targeting a repository set up on above address this manually cached credential will be used.

Note:

  1. If you have Git bash command line already open then close it and reopen it for changes to take effect.
  2. Also remember that when your domain account password expires next time (may be due to corporate rotational password policy) then you'll have to update the password on this screen as well. You can do this after setting up a new password for your domain account.


Go to > Control Panel\User Accounts\Credential Manager > Manage Windows Credentialsand remove all generic credentials involving Git. (This way you're resetting all the credentials)

After this, when you clone, you'll be newly and securely asked your Git username and password instead of Authentication error. Similar logic can be applied for Mac users using Sourcetree.

Hope it helps.


Adding username and password has worked for me: For e.g.

https://myUserName:myPassWord@myGitRepositoryAddress/myAuthentificationName/myRepository.git