380

I am on mac OS unlike this post:

I have password configured in GitLab.

I have 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:

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

I am prompted to enter my GitLab username and password. After password is entered I get:

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

Regolith
  • 2,676
  • 9
  • 30
  • 42
jeancode
  • 3,996
  • 3
  • 10
  • 19
  • Following answers didn't work for me..If still anyone facing this issue in mac...this link might help... https://stackoverflow.com/questions/17659206/git-push-results-in-authentication-failed – PALLAMOLLA SAI Apr 13 '20 at 12:42

41 Answers41

766

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

Try below solution which works for me:

  1. Go to Windows Credential Manager. This is done in a 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.
Mehrdad Mirreza
  • 794
  • 8
  • 20
mpro
  • 10,634
  • 4
  • 20
  • 35
237
   git config --system --unset credential.helper

then enter new password for Git remote server.

coder
  • 6,805
  • 15
  • 34
  • 47
hatanooh
  • 2,661
  • 1
  • 11
  • 7
  • 29
    Note that on Windows you need to run it as Administrator, otherwise you'll get permission errors – Eternal21 Aug 05 '18 at 01:34
  • 9
    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` – Vincent Lunat Oct 15 '18 at 10:24
  • 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` – Ghostrydr Oct 17 '18 at 16:43
  • git config --system credential.helper manager, to use credential.helper again. – hatanooh Feb 19 '19 at 01:43
  • 5
    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 – Tomasz Czechowski Sep 02 '19 at 07:05
  • What if you don't have administrator access? – Not a bug May 19 '20 at 07:52
  • 1
    If you don't have administrator access omit --system or --global flag and set the credential helper only for your current git repository – Juan Rojas Nov 16 '20 at 16:31
131

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, go to: (Right corner) Personal Profile->Settings-> Access Tokens
  • enter image description here
  1. Create a new personal access token (check api)
  • enter image description here
  1. git clone ...
  2. When you are asked for your password, copy and paste the access token instead of your GitLab password
  • enter image description here
crifan
  • 8,424
  • 1
  • 45
  • 35
JavAlex
  • 1,504
  • 1
  • 9
  • 12
116

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...

Barry Michael Doyle
  • 6,372
  • 18
  • 63
  • 110
Bharti Ladumor
  • 1,365
  • 1
  • 7
  • 15
  • 12
    If you get that error, you can just run your command prompt as Administrator, and the error goes away. – Eternal21 Aug 05 '18 at 01:33
  • 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. – yardpenalty.com Mar 15 '19 at 15:34
  • 3
    also try it this way with **--global** `git config --global --unset credential.helper` – Mike Aug 24 '19 at 02:06
  • deleting gitconfig file i get error: "error setting certificate verify locations: cafile" – Alexbogs Dec 01 '20 at 11:51
59

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

Paulo Morgado
  • 11,247
  • 2
  • 24
  • 48
  • 1
    Great answer it works fine for me because my git was private, Thank you – Mohammad H. Jul 02 '18 at 09:51
  • Thanks. Although for me have to replace it with SSL repo url but your answer make me help out. I have upvoted it. – Muzzamil Apr 01 '20 at 13:56
  • 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:personalAccessTokenHere@gitlab.com/usernameHere/projectNameHere` – Woppi Jun 19 '20 at 03:26
  • Yep this worked, but it's quite gnarly to put in every time. It used to just work in the past, weird... – IamLasse Nov 27 '20 at 12:59
43

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

JJJ
  • 31,545
  • 20
  • 84
  • 99
Andy Quiroz
  • 729
  • 4
  • 8
32

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

barbsan
  • 3,238
  • 11
  • 18
  • 27
Kshama Jain
  • 321
  • 3
  • 3
  • 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. – k4yaman Dec 02 '19 at 12:18
27

Just add your username before the domain:

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

And the assistant will ask you the password

gal007
  • 5,504
  • 5
  • 35
  • 58
22

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

Pigueiras
  • 17,275
  • 9
  • 58
  • 83
16

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.

halfer
  • 18,701
  • 13
  • 79
  • 158
Vikash Pandey
  • 5,073
  • 6
  • 36
  • 41
14

Try this:

  1. Go to: C:/Users/(YourUserName)/
  2. Delete file .gitconfig
Stephen Rauch
  • 40,722
  • 30
  • 82
  • 105
boy_vkallstar
  • 141
  • 1
  • 3
14

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

Dyno Cris
  • 712
  • 5
  • 14
  • 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. – John Ranger Sep 10 '19 at 12:41
13

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.
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 1
    - 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 Dec 18 '17 at 19:32
  • @jeancode I mean: what do you see when you type `git config credential.helper`: that could have cached the wrong credentials. – VonC Dec 18 '17 at 20:15
  • @jeancode For the space, did you percent encode it? (https://en.wikipedia.org/wiki/Percent-encoding#Character_data: %20) – VonC Dec 18 '17 at 20:15
  • I didn't do anything to the space in the name, the space comes from my name in GitHub, that GitLab grabbed during authentication login through Github. – jeancode Dec 19 '17 at 01:42
  • "authentication login through Github"... that does not looks like "my GitLab username and password". GitHub should not be involved here. – VonC Dec 19 '17 at 07:40
  • It is involved because you can Login to Gitlab through Github... Like I said, my name has a space in it because of my name in Github. Gitlab allows a user to authenticate signing in through Github. – jeancode Dec 20 '17 at 20:11
  • @jeancode I understand. Still, check what `git config credential.helper` returns. – VonC Dec 20 '17 at 20:13
  • this is the output `osxkeychain` – jeancode Dec 22 '17 at 21:36
  • @jeancode Then delete any credentials (https://help.github.com/articles/updating-credentials-from-the-osx-keychain/#deleting-your-credentials-via-the-command-line) in it related to github.com and gitlab.com, and try again. – VonC Dec 22 '17 at 21:37
  • 1
    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. – Joshua Dyck Oct 15 '19 at 20:55
  • 3
    I solved, just editing the password of GitLab in Windows Credentials, Thanks! – joelmez4 Jul 06 '20 at 15:15
12

Open command prompt as administrator then run this command:

git config --system --unset credential.helper
10

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:YOUR_TOKEN@gitlab.com/PROFILE_NAME/REPO_NAME.git/

Gaurav
  • 311
  • 3
  • 5
9

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.

Artorias2718
  • 503
  • 5
  • 10
  • for more info, see: `git config -l`. Also try above with `--global` instead of `--system` – Mike Aug 24 '19 at 02:14
9

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
8

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

SanjX
  • 509
  • 1
  • 5
  • 8
5

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

saiedkia
  • 49
  • 1
  • 4
4

In my case I reinstalled to the latest version of git (currently 2.16.2). I don't know if it was that my old version of git was outdated, but I read on a github page that this should be done if you stumble into https cloning errors. I figured it was an https cloning error as the error focuses on HTTP Basic, while GitLab uses HTTPS. I might be wrong in this thought process, but the solution helped in my case, and I hope this helps anyone in the future!

Andreas Forslöw
  • 1,344
  • 14
  • 24
4

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

yourUserName@STAuth-gitlab.yourAdress

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

Burcu Kutluay
  • 281
  • 2
  • 12
4

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.

NicolasElPapu
  • 1,285
  • 1
  • 7
  • 22
rotoava
  • 575
  • 6
  • 18
4

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

Sitecore Sam
  • 257
  • 2
  • 6
  • 12
3

GO TO C:\Users\<<USER>> AND DELETE THE .gitconfig file then try a command that connects to upstream like git clone, git pull or git push. You will be prompted to re-enter your credentials. Kindly do so.

prashant17
  • 1,487
  • 3
  • 11
  • 20
3

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.
3

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 = git@gitlab.com:prat3ik/my-project.git

And it was working!!

Pratik Patel
  • 1,424
  • 2
  • 16
  • 28
2

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.
Gani
  • 318
  • 1
  • 4
  • 15
2

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.

Momchill
  • 327
  • 2
  • 11
2

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.

lkostka
  • 493
  • 3
  • 10
2

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
samuelj90
  • 6,484
  • 2
  • 35
  • 38
1

When the Windows Credential Manager asks for your credentials to access GitLab, those are username and password you use when accessing GitLab. EG: use your email and password.

aercolino
  • 1,707
  • 1
  • 17
  • 17
1

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.

ATOMP
  • 855
  • 5
  • 21
1

On mac use KeyChain -> Login -> Password: change password

Yu Jiaao
  • 3,486
  • 4
  • 34
  • 52
1

I had to do below two steps to resolve this issue

  1. create ssh-keygen and add the public key to my gitlab account

  2. disable https using below command

    git config --global http.sslVerify false

enter image description here

Mateen
  • 1,353
  • 1
  • 16
  • 24
0

I tried with browser URL for the repository then

git clone $(browserURL)

it prompted for my username and then my password

It worked fine then

Saurabh Verma
  • 798
  • 1
  • 12
  • 25
0

go to credential setting on your windows computer and Remove https://gitlab.com/sobopla/Geronimod.git

0

Just for reference, I encountered this issues while using the URL wrongly after I generated and pasted the ssh_rsa.pub to the SSH Keys in gitlab.

$ git clone http://gitlab.x
Cloning into 'start-up'...
remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'api' scope for Git over HTTP.
remote: You can generate one at http://gitlab.x

Solved by using the following URL instead.

$ git clone gitlab@gitlab.xxx.com/your_project.git
Hearen
  • 6,019
  • 2
  • 36
  • 50
0

I've faced this same issue after once I've entered the wrong credentials of my git account. The thing that did work for me is, open keychain Access -> Password -> find your entered wrong password and update it and hit save, after that you will be able to perform your operations on git without any issue.

I hope this works for you.

0

I had the same issue but before I went ahead to implement any of the suggestions on here, I checked if I was still logged into my github account. I had the problem while working in my Gitlab account. I found out I was still logged into my Github account and I logged out of the account immediately. I tried to clone again in Gitlab and I didn't have the error and the clone was successfully.

Othello
  • 75
  • 9
-1

Create a new access token from gitlab ->setting --> access token

-1

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.

Badr
  • 107
  • 5
  • 11