614

Unlike this post, I am on macOS.

I have the password configured in GitLab. I also have an SSL key created after the project was made on GitLab.

When I use an existing folder for a new project and follow the steps below, I am prompted to enter my GitLab username and password.

Existing folder

cd existing_folder
git init
git remote add origin https://gitlab.com/sobopla/Geronimod.git
git add .
git commit -m "Initial commit"
git push -u origin master

After the password is entered I get the following error.

remote: HTTP Basic: Access denied fatal: Authentication failed for 'https://gitlab.com/myname/myproject'

6
  • Following answers didn't work for me..If still anyone facing this issue in mac...this link might help... stackoverflow.com/questions/17659206/… Commented Apr 13, 2020 at 12:42
  • This error can also occur if your GitLab account has as password expiration date set but you are using another authentication method, e.g. LDAP. Then GitLab throws the 403 without even checking your credentials against the LDAP server. Commented Jun 10, 2021 at 12:56
  • Penaltily related question: macos - How do I update the password for Git? - Stack Overflow Commented Jun 1, 2022 at 3:03
  • One workaround is to authenticate using SSH rather than HTTP. In the steps above, that would mean replacing the third line with git remote add origin [email protected]:sobopla/Geronimod.git. This should if you have your SSH keys set up properly. Commented Aug 31, 2022 at 19:25
  • I'm surprised no one has suggested the first thing that you should do. Double-check your username and password! Commented Sep 6, 2022 at 10:10

60 Answers 60

991

It happens every time I'm forced to change the Windows password and none of the above answers helped me.

Try the below solution which works for me:

  1. Go to Windows Credential Manager. This is done in an EN-US Windows by pressing the Windows Key and typing 'credential'. In other localized Windows variants you need to use the localized term (See comments for some examples).

    alternatively you can use the shortcut control /name Microsoft.CredentialManager in the run dialog (WIN+R)

  2. Edit the git entry under Windows Credentials, replacing old password with the new one.

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

19 Comments

Thanks, that worked for me as well and solved the problem. You need this solution if you have different Github accounts on your device
It worked for me too though i am using multiple gilab accounts so what i did i updated my all the gitlab account with the same password that i have in my Credential Manger and the problem is solved Thanks@mpro
Note: type it in your language system. Rus: "Credential Manager" = "Диспетчер Учетных Данных"
In German it is "Anmeldeinformationsverwaltung" and then "Windows-Anmeldeinformationen".
In French it is "Gestionnaire d’informations d’identification".
|
567

For me, the following worked:

Do not use your GitLab password, but create an access token and use it instead of your password:

  1. In GitLab, at the top-right corner, go to Personal Profile → Settings → Access Tokens Step 1

  2. Create a new personal access token (check the api option) Step 2

  3. git clone ...

  4. When you are asked for your password, copy and paste the access token instead of your GitLab password

    Step 3

21 Comments

Alternatively, on Windows, replace the password in Windows Credential Manager for the token.
I had already created a token but didn't know that after this you login with it instead of the password. Thanks for the tip.
This should be the accepted answer. It is necessary in some projects according to the security configuration. Gitlab password will never work, just create and use your token. (Save your token in a secure place for future uses).
LOL, didnt found any place telling me that I should use access token in password field...
Doesn't work for me, got no idea why, I've been cracking my head at this for far too long
|
370

You can try the following command:

git config --system --unset credential.helper

Then, enter a new password for Git remote server.

9 Comments

Note that on Windows you need to run it as Administrator, otherwise you'll get permission errors
It depends where you put your credentials. If the previous command does not work try also using global flag: git config --global--unset credential.helper
This is the most relevant answer for the OP as it addresses the issue, and doesn't go on some "on Windows" tangent. Also, as a side note, you may need to run this command as sudo if your user doesn't have access to /etc
If you unset credential helper, you would have to provide username and password each time connecting to the GIT repository. To fix that you can set helper again by using the following command: git config --global credential.helper store
If you don't have administrator access omit --system or --global flag and set the credential helper only for your current git repository
|
140

I got the same error and I solved this by :

  1. Apply command from cmd (run as administrator)

    git config --system --unset credential.helper

  2. And then I removed gitconfig file from C:\Program Files\Git\mingw64/etc/ location (Note: this path will be different in MAC like "/Users/username")

  3. After that use git command like git pull or git push, it asked me for username and password. applying valid username and password and git command working.

hope this will help you...

5 Comments

If you get that error, you can just run your command prompt as Administrator, and the error goes away.
FYI: Just resetting the config (your first cmd) worked. I then did my git push and blammo! I think its because my shop requires monthly password changes so the internal git lab goes haywire.
also try it this way with --global git config --global --unset credential.helper
deleting gitconfig file i get error: "error setting certificate verify locations: cafile"
This works but it keeps asking me to enter my credentials for every pull command now. How do I set the credentials once and for all?
97

The only thing that worked for me was using https://username:[email protected]/user/projectgit instead of https://gitlab.com/user/projectgit. See https://gitlab.com/gitlab-com/support-forum/issues/1654

3 Comments

Thanks. Although for me have to replace it with SSL repo url but your answer make me help out. I have upvoted it.
Thanks. I didn't have such issue when using BitBucket or Github. With GitLab I have to create personal access token, then use that in remote origin git remote set-url origin https://usernameHere:[email protected]/usernameHere/projectNameHere
This always work for me
54

Go to Windows Credential Manager (press Windows Key and type 'credential') to edit the git entry under Windows Credentials. Replace old password with the new one.

Windows Credential Manager

3 Comments

OP is on macOS, not Windows.
This wouldn't help OP, but it worked like a charm on my Windows dev box.
Though it is in Spanish, it helped me adding Git credentials in Windows. I entered control /name Microsoft.CredentialManager command, selected Windows credentials (not Internet credentals), than added Windows credentials (I wondered why haven't they already existed there). Added similar to git.company.name, name and password. When pushed a new branch to Git repository, Windows asked a name and new password.
48

Just add your username before the domain:

https://**username**@gitlab.com/user/projectgit

And the assistant will ask you the password

2 Comments

https://<username>:<password>@gitlab.com/user/project.git
@SalehRahimzadeh be aware that using the password in the URL will store the password in the .git/config file in plaintext
37

I was also facing the same issue. The reason for the problem was authentication error. To solve this problem go to Control Panel -> Credential Manager -> Generic Credentials here find your gitlab credential and edit them. Make sure your ID password is right or not

enter image description here

1 Comment

This did the trick, in my case it was because the company forces us to change the domain password every few months. This change didn't update the credentials in this credential manager. As soon as I updated the password it was working.
35

If you are using git > 2.11 and using Kerberos to interact with Gitlab you need set this configuration in your local git to avoid the remote: HTTP Basic: Access denied error.

$ git config --global http.emptyAuth true

Source

4 Comments

I'm not using Kerberos but thank you for your reply.
Kerberos aren't necessary. Thanks! git-scm.com/docs/git-config
After doing a clean install of Git on Windows this morning. This answer solved Access denied error for me.
Holy cow - I went through all the other suggestions and finally FINALLY this one worked. Indeed was using Kerberos!
29

Well, I faced the same issue whenever I change my login password.

Below is the command I need to run to fix this issue:-

git config --global credential.helper wincred

After running above command it asks me again my updated username and password.

Comments

21

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

2 Comments

Thanks @chuklore great to see people looking to understand the issue and not just quick fixes.
You are right. I saw my Gitlab credentials had a different username and password. Worked immediately it was changed. I can even clone via HTTPs now which is cool. Thanks
20

2017: Note: do not mix GitLab SSL settings and GitLab SSH keys.

If what you have configured in your GitLab profile is an SSH public key, then your HTTPS URL would not use it.

Regarding your HTTPS credentials, double-check:

  • if the two-factor authentication is disabled, or
  • if you have special characters in your username or password, or
  • if you have a Git credential helper: git config credential.helper.

2024: as noted by Esmaeele in the comments:

IF 2FA is enabled we cant access to some gitlab features with password. We must create a Personal Access Token(PAT) then Use it instead of user password. In user_settings/personal_access_tokens.

See my other answer at "GitLab - Disable 2FA for only one user in an organization".

15 Comments

- I have a space in my username because I authenticated Gitlab through Github - Two-factor autentication is disabled - What do you mean "If I have a Git credential helper?
@jeancode I mean: what do you see when you type git config credential.helper: that could have cached the wrong credentials.
I was getting the error due to trying to use deploy keys while two factor authentication was enabled. Apparently you can only use personal access tokens if two-factor is enabled.
I solved, just editing the password of GitLab in Windows Credentials, Thanks!
@EsmaeelE Thank you, I had forgotten my other answer you are referencing in your comment. I have edited this answer accordingly.
|
17

I beleive I'm little late here. But I think this would help the new peeps!

My Errors were: remote: HTTP Basic: Access denied

remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.

remote: You can generate one at https://gitlab.com/profile/personal_access_tokens

fatal: Authentication failed for 'https://gitlab.com/PROFILE_NAME/REPO_NAME.git/'

I'm on Ubuntu but this worked for me:

  1. Goto https://gitlab.com/profile/personal_access_tokens
  2. Create new token and mark check to all.
  3. Copy your token
  4. Now go to your Terminal and paste it like this.

git clone https://oauth2:[email protected]/PROFILE_NAME/REPO_NAME.git/

3 Comments

<USERNAME>:<PERSONAL_TOKEN>@gitlab.com/<USERNAME>/<REPO_NAME>.git works for me when configuring a "Mirroring Repository"
You sir, are my hero today!
For me with out profile name worked. git clone oauth2:[email protected]/REPO_NAME.git
16

Open command prompt as administrator then run this command:

git config --system --unset credential.helper

3 Comments

could not lock config file C:\Program Files\Git\mingw64/etc/gitconfig: Permission denied
You do not use config file, just open you command prompt as administrator and run the command. Hope this helps
try with sudo git config --system --unset credential.helper
16

It happens if you change your login or password of git service account (GitHub or GitLab, Bitbacket, etc). You need to change it in Windows Credentials Manager too.

So, type "Credential Manager" (rus. "Диспетчер Учетных Данных") in Windows Search menu and go to your git service account and change data too.

enter image description here

1 Comment

Although I didn't change my user or password (it is an AD credential), this happened to me because of a rebuild of the Gitlab server and the above solution has fixed this error.
12

There are two ways I got around this problem:

  1. I added my username to the front of the remote URL (https://username@gitRepoURL)

    • Not always the best solution; where I work, even though we're slowly moving towards using GIT, we have our applications on a network drive, so if I do this, only I can push changes even if someone else worked on a feature.
  2. I can't run git config --system --unset credential.helper from GIT Bash, so I had to open up an Admin Command Prompt and run it there (this assumes you installed GIT such that it can run from both GIT Bash and the Command Prompt). From Bash, I get a "could not lock config file" error.

1 Comment

for more info, see: git config -l. Also try above with --global instead of --system
11

It is certainly a bug, ssh works with one of my machines but not the other. I solved it, follow these.

  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

1 Comment

Yeah, answers above did not work for me, and this was straightforward - "git remote set-url origin https://new-token-name:[email protected]/path/to/repo/"
10

Try this:

  1. Go to: C:/Users/(YourUserName)/
  2. Delete file .gitconfig

1 Comment

do not do this one, this kills your settings in general
10

Same problem with Sourcetree On Mac

Solution: Delete the password in keychain access.

enter image description here

https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-quot-fatal-Authentication-failed-for-quot/qaq-p/201844

When you try to push again it will ask for your password.

1 Comment

Did not work for me in Mac, It keeps failing with error HTTP Basic: Access denied. The provided password or token is incorrect
8

Go to Control Panel->Credential Manager->Windows Credentials select github or gitlab credentials and modify it. This is for windows10

Comments

8

When I had the same problem,

I solved it by removing the file "passwd" in

C:\Users\<USERNAME>\AppData\Local\Atlassian\SourceTree

After removing Sourcetree will prompt for the password.

Note:
OS Version : win10 
Sourcetree Version:  3.1

2 Comments

This solved my issue on source tree.
This solved my issue with the Sourcetree.
8

For me it was some other git URL placed in config file, so I did change it manually:

  1. Move to .git/config file and edit it,
  2. Remove invalid URL(if it's there) and paste the valid git SSH/HTTP URL like below way:
[remote "origin"]
        url = [email protected]:prat3ik/my-project.git

And it was working!!

Comments

8

I had the same problem using GitLab, and here's how i fixed it:

  1. Generate an access token: to do so go to settings/access tokens, then give it a name and expiration date and submit.

  2. In your project files open the "config" file in ".git" directory: /.git/config.

  3. You will find a line like this:

    [remote "origin"] url = https://[username]:[token]@your-domain.com/your-project.git

  4. You will have your gitlab username instead of [username], and you should replace [token] with your token generated in step 1.

  5. Save the changes.

Comments

7

i removed gitlab credential from 'Credential Manager' in windows and pushed successfully

Comments

6

For Mac user:

  1. Go to keychain and delete gitlab accounts
  2. Go to your project path in terminal and simply type git pull
  3. Then you will be asked for username and password for gitlab
  4. Enter your username which you will find out in gitlab account in profile section.
  5. Then after that enter you updated password here.
  6. Here we go, again try to push your code, it may help you guys.

Comments

6

Strangely enough, what worked for me was to sign out and sign back in to the GitLab web UI.

I have no earthly idea why this worked.

1 Comment

sign out didn't work for me. 1) I changed password on GitLab WebUI. 2)Open terminal. 3) Checkout branch -> Git pull. it ask for username/password. I entered new password. Then it worked on terminal and Git Client.
5

If your trying to login Gitlab with your existing Git account. You need to reset your password of Gitlab, for the first time.

  1. Step: Navigate to setting by clicking your profile icon( drop down menu on top right corner).
  2. Step: Go to settings
  3. Step: Click on the lock icon or glyphicon icon(i.e password).
  4. Step : Enter the new password for Gitlab.

Comments

5

it worked for me: I use Mac and I wrote the path on finder:

~/Library/Application Support/SourceTree

I deleted the auth file which should be like

[email protected]

then tried to push and pull the code from the source tree and it worked.

You can also read the following answers:

https://community.atlassian.com/t5/Sourcetree-questions/How-to-update-HTTP-S-credentials-in-sourcetree/qaq-p/297564

Comments

5

So for me the problem was that I had created my GitLab account via linking my GitHub account to it. This meant that no password formally existed for the account as it was created via hotlink between GitHub and GitLab. I fixed it by going to GitLab Settings -> Password -> and writing the same password as my GitHub account had.

Comments

5

None of the above solutions worked for me and I don't have admin rights on my laptop, but they eventually led me to the git tools credential storage doc :

My setup Windows 10 | git version 2.18.0.windows.1 | Clone through HTTPS link

This solution works if you use wincred as credential helper :

> git config --global credential.helper
wincred

Changing the helper to "cache" should do the trick, as it will ask you to provide your credentials again. To set it to cache, just type :

> git config --global credential.helper cache

Check your update is active:

> git config --global credential.helper
cache

You should now be able to clone / pull / fetch as before.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.