Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'git push origin MyBranchName' throws error "HTTP Basic: Access denied"

Tags:

git

gitlab

I am new to Git (just started 2 days ago). I'm attempting to create a project to practice the basic commands I've learned from here.

Where I am, so far:

  • [success] Create a new public git project (because I tried private and internal before but I could not clone it, and I don't know why). Here it is.
  • Added a README.md into the project.
  • [success] Create a new branch named develop.
  • [success] In my local folder C:\gitprojects, set global user.name and user.email with the commands:

    • git config --global user.name <my user name>
    • git config --global user.email <my-email>
  • [success] Clone the project into my local folder C:\gitprojects with the command git clone https://[email protected]/flamedenise19/speedtyping.git

  • [success] Create a local branch with the command git checkout -b "develop".
  • [success] Manually add a new file test.txt on local root folder for test pushing.
  • [success] Commit the new file with the command git commit -m "adds test.txt"
  • [attempting] Push the commit with the command git push origin develop

And now, I'm stuck with the push part. After entering git push origin develop, a new window pops up, asking for my credentials (see screenshot below):

enter image description here

So I did enter my credentials (the very same username and password I use when logging in to gitlab.com), but after that, I got this error (also see screenshot below):

remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/flamedenise19/speedtyping.git/'

enter image description here

QUESTIONS:

  • Why can't I push successfully, even with the correct username and password? Am I missing something or have I done something wrong along the way?
  • Is there a way to remove the step of having to enter my credentials everytime I push something?

Please help.

NOTE: I have seen THIS ONE, and the answers are mentioning Tortoise. Is it always required to use tortoise in order to use Git?

SOME BACKGROUND INFO:

Two-Factor Authentication is disabled for my account (see screenshot below):

enter image description here

like image 735
ITWitch Avatar asked Mar 29 '17 05:03

ITWitch


People also ask

How do I authenticate git in terminal?

There are three main approaches you can take: Using a personal authentication token or password. Using an SSH key. Using your GitHub password with 2-factor authentication.

How do I add git credentials in Windows?

Or finding it via the Control Panel -> Manage Windows Credentials. Go to Windows Credentials -> Generic Credentials. Here your credential should be listed if everything is working correctly. Git should add it by default the first time you log in to a new repository.

What is git Credential Manager?

Git Credential Manager creates and stores credentials to access Git repositories on a host of platforms. We hold in the highest regard the need to keep your credentials and access secure. That's why we always keep your credentials stored using industry standard encryption and storage APIs.


3 Answers

If it is on windows, go to Credential Manager, Windows Credentials and Delete the entries under Generic Credentials.

Try connecting again. This time, it should prompt you for the correct username and password.

like image 98
Matoeil Avatar answered Nov 05 '22 01:11

Matoeil


These are my ideas:

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

like image 37
Kai Avatar answered Nov 05 '22 00:11

Kai


After doing some digging of my own thanks to this problem I found out that it is more than likely coming from the credential manager. I had no ssh keys since it was a fresh Gitlab account and it was not working with my username and password. The same setup however, was working on GitHub. After uninstalling git and reinstalling without the credential manager it worked.

like image 3
djc40 Avatar answered Nov 05 '22 00:11

djc40