50

I use GitLab Community Edition 9.1.3 2e4e522 on Windows 10 Pro x64. With Git client.

Error

Cloning into 'project_name'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'http://my_user_name@example.com/my_user_name/project_name.git/'

How to fix it?

Do Nhu Vy
  • 33,131
  • 37
  • 143
  • 202
  • I got this issue in macOS High Sierra(10.13.5).How to fix it? – IKKA Sep 05 '18 at 04:33
  • (I am not sure) On maCOS you open keychain, then remove credential https://support.apple.com/en-vn/guide/keychain-access/what-is-keychain-access-kyca1083/mac – Do Nhu Vy Sep 05 '18 at 04:35
  • I removed credential from keychain access.Still appear same error. – IKKA Sep 05 '18 at 05:16
  • Answer is already given here https://stackoverflow.com/questions/47860772/gitlab-remote-http-basic-access-denied-and-fatal-authentication – Devashish May 29 '20 at 15:05

14 Answers14

85

Open CMD (Run as administrator) type command:

git config --system --unset credential.helper

then enter new password for Git remote server.

Do Nhu Vy
  • 33,131
  • 37
  • 143
  • 202
  • 3
    Removing or disabling the Git credential manager for Windows isn't really a solution to this problem. People have and use it because it's a necessary part of their workflow; perhaps because they use GitHub too. This repository needs to "just work" with it transparently. – Sébastien Jul 27 '17 at 09:00
  • 8
    What does this do? – Mohammad Kermani Jan 23 '18 at 12:45
  • 9
    doesn't work: gives error: could not lock config file /etc/gitconfig: Permission denied – Schroeder Mar 23 '18 at 15:38
  • 4
    It depends where you put your credentials. If the previous command does not work try also using global flag instead of system: `git config --global--unset credential.helper` – Vincent Lunat Oct 15 '18 at 10:27
  • 1
    run command as administrator, nothing happens. (windows7, gitlab) – Cho Aug 07 '19 at 09:26
  • 1
    perfect solution, this usually happens when your git password has changed and your system's git credential helper is looking to authenticate using the older token. Do this to unset your credentials and re run your git command. It should ask for an authentication after that you're good to go. – geekidharsh Jan 15 '20 at 18:38
  • error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied – saber tabatabaee yazdi Feb 15 '20 at 20:48
  • 1
    @sabertabatabaeeyazdi You have to run cmd as administrator. Try rerunning the command after that. – prohit May 25 '20 at 12:43
26

Im my case i was using Git Credential Manager for Windows (it was installed by default, I didn't install it manually)

Credentials Manager had saved my old password but i changed it lately.

If you are in the same conditions, to solve this problem: Go to Control Panel -> Credentials Manager and delete git account. After that it will ask you again for the credentials.

KlevisGjN
  • 595
  • 2
  • 8
  • 15
11

For my case, I initially tried with

git config --system --unset credential.helper

But I was getting error

error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied

Then tried with

git config --global --unset credential.helper

No error, but still got access denied error while git pulling.

Then went to Control Panel -> Credentials Manager > Windows Credential and deleted git account.

After that when I tried git pull again, it asked for the credentials and a new git account added in Credentails manager.

Deb
  • 121
  • 1
  • 3
  • Control Panel -> Credentials Manager > Windows Credential and Edit Worked for me for 2 options under gitlab accounts. – Farhan Khan May 07 '21 at 06:39
8

i coped with same error and my suggestion are:

  1. Start with try build another user in git lab
  2. Recheck username & password (although it sounds obvious)
  3. Validate the windows cerdential (start -> "cred")
  4. Copy & paste same URL like you get from git lab, the struct should be:

http://{srvName}/{userInGitLab}/{Repository.git} no '/' at the end

  1. Recheck the authorization in GitLab
  2. Give an attention to case sensitive

Hope one of the above will solve it.

shdr
  • 784
  • 7
  • 24
  • 1
    That's work! I have the wrong password typo at the first time, just change it in the windows credential. there is no way to re-input from git-tortoise. – HATCHA Jan 07 '19 at 08:57
5

This can happen also because of a change in the password and since Git Credential Manager caches it, so if that's the case 1. Open Credential Manager in Windows 2. Search for your GIT credential and reset it to the new password.

5

When it asks for username and password. Just add gitlab user name and password for clonning. For the box to pop up asking credentials, do the following:

go to "control panel"-> user accounts-> manage credentials->windows credentials->git:https://username@gitlab.com->click on down arrow-> then click remove.

Hope this helps!

Sidso
  • 77
  • 1
  • 10
3

Go to your Credential manager => git credentials Check your git credentials and check your password.

This worked for me.

sai
  • 79
  • 1
  • 6
1

A simple git fetch/pull command will throw a authentication failed message. But do the same git fetch/pull command second time, and it should prompt a window asking for credential(username/password). Enter your Id and new password and it should save and move on.

jsimon
  • 27
  • 1
1

I use VS Code on my mac OS and GitLab for my project. I tried so many ways but it worked simply for me by resetting the remote origin of your project repository with the below command:

cd <local-project-repo-on-machine>
git remote set-url <remote-name> <remote-url>

for ex: git remote set-url origin https://<project-repository>.git

Hope it helps someone.

Aditya
  • 176
  • 2
  • 6
0

Edit the entry(possibly the password field that may have changed) for git: inside Generic Credentials section of Windows Credentials which can be accessed from Control Panel. Please note this is for Windows OS.

0
  1. Generate an access token with never expire date, and select all the options available.
  2. Remove the existing SSH keys.
  3. Clone the repo with the https instead of ssh.
  4. Use the username but use the generated access token instead of password.

enter image description here

alternatively you can set remote to http by using this command in the existing repo, and use this command git remote set-url origin https://gitlab.com/[username]/[repo-name].git

Sitecore Sam
  • 257
  • 2
  • 6
  • 12
0

Before digging into the solution lets first see why this happens.

Before any transaction with git that your machine does git checks for your authentication which can be done using

  1. An SSH key token present in your machine and shared with git-repo(most preferred) OR
  2. Using your username/password (mostly used)

Why did this happen

In simple words, this happened because the credentials stored in your machine are not authentic i.e.there are chances that your password stored in the machine has changed from whats there in git therefore

Solution

Head towards, control panel and search for Credential Manager look for your use git url and change the creds.

There you go this works with mostly every that windows keep track off

Manasvi Mittal
  • 111
  • 1
  • 5
0

The updating of the password in the windows credential manager was not the solution for me.

I had to set a different remote url, by:

git remote set-url origin https://gitlab....git

The url in this case was the one that could be found in Gitlab under Clone -> Clone with HTTPS. It was not the one in the command line instructions.

LaurinO
  • 113
  • 6
-2
  • Try if it works on the Git Bash
  • Have you added a ssh key to your account? If yes remove it and try again. If not add one and try the ssh url.
  • You don't necessarily need Tortoise Git but it may also work around your problem
  • Try to re-install Git without the Git Credential Manager for Windows

When you've fixed the push problem you will also be able to clone it when it is private or internal.

Rohit Poudel
  • 1,604
  • 2
  • 16
  • 19