[git] GitHub: invalid username or password

I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message

Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://[email protected]/eurydyce/MDANSE.git/'

However, setting my ssh key to github seems ok. Indeed, when I do a ssh -T [email protected] I get

Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.

Which seems to indicate that everything is OK from that side (eurydyce being my github username). I strictly followed the instructions given on github and the recommendations of many stack discussion but no way. Would you have any idea of what I may have done wrong?

This question is related to git github

The answer is


just try to push it to your branch again. This will ask your username and password again, so you can feed in the changed password. So that your new password will be stored again in the cache.


You might be getting this error because you have updated your password. So on Terminal first make sure you clear your GitHub credentials from the keychain and then push your changes to your repo, terminal will ask for your username and password.


When using the https:// URL to connect to your remote repository, then Git will not use SSH as authentication but will instead try a basic authentication over HTTPS. Usually, you would just use the URL without a username, e.g. https://github.com/username/repository.git, and Git would then prompt you to enter both a username (your GitHub username) and your password.

If you use https://[email protected]/username/repository.git, then you have preset the username Git will use for authentication: something. Since you used https://[email protected], Git will try to log in using the git username for which your password of course doesn’t work. So you will have to use your username instead.

The alternative is actually to use SSH for authentication. That way you will avoid having to type your password all the time; and since it already seems to work, that’s what you should be using.

To do that, you need to change your remote URL though, so Git knows that it needs to connect via SSH. The format is then this: [email protected]:username/repository. To update your URL use this command:

git remote set-url origin [email protected]:username/repository

I had the same issue. And I solved it by changing the remote branch's path from https://github.com/YourName/RepoName to [email protected]:YourName/RepoName.git in the repo's settings of the client app.


I did:

$git pull origin master

Then it asked for the [Username] & [Password] and it seems to be working fine now.


I'm constantly running into this problem. Make sure you set git --config user.name "" and not your real name, which I've done a few times..


There is a issue on Windows using cmd-Greetings

There is a issue on Windows using cmd-Greetings who will not let you clone private repositories. Remove that cmd-greeting described in this documentation (keyword Command Processor):

Known-Issues

I can confirm that other clients like SourceTree, GitKraken, Tower and TortoiseGit affected to this issue too.


I have got the success using the following commands.

git config --unset-all credential.helper
git config --global --unset-all credential.helper
git config --system --unset-all credential.helper

Try and let me know if these are working for you.


I just disable the Two-factor authentication and try again. It works for me.


Disabling 2 factor authentication at github worked for me.

I see that there is a deleted answer that says this, with the deletion reason as "does not answer the question". If it works, then I think it answers the question...


After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone, git fetch, git pull or git push:

$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'

Why this is happening

From the GitHub Help documentation:

After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password.

...

For example, when you access a repository using Git on the command line using commands like git clone, git fetch, git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password.

How to fix it

  1. Generate a Personal Access Token. (Detailed guide on Creating a personal access token for the command line.)
  2. Copy the Personal Access Token.
  3. Re-attempt the command you were trying and use Personal Access Token in the place of your password.

Related question: https://stackoverflow.com/a/21374369/101662


I am getting this while cloning app from bitbucket:

Cloning into 'YourAppName'...
Password for 'https://youruser id': 
remote: Invalid username or password

I solved it. Here you need to create password for your userid

  1. Click on Your profile and settings Click on Your profile and settings

  2. Then Create app password choose your name password will generated ,paste that password to terminal Create app password


Since you probably want to keep 2FA enabled for your account, you can set up a ssh key and that way you won't need to type your Github credentials every time you want to push work to Github.

You can find all the ssh setup steps in the documentation. First, make sure you don't currently have any ssh keys (id_rsa.pub, etc.) with $ ls -al ~/.ssh


No need to rely on Generating a Personal Access Token and then trying and use Personal Access Token in the place of your password.

Quick fix is to set your remote URL to point to ssh not https.

Do this git remote set-url origin [email protected]:username/repository


Instead of git pull also try git pull origin master

I changed password, and the first command gave error:

$ git pull
remote: Invalid username or password.
fatal: Authentication failed for ...

After git pull origin master, it asked for password and seemed to update itself


If like me you just updated your password and ran git push to run into this issue, then there's a super easy fix.

For Mac users only. You need to delete your OSX Keychain access entries for GitHub. You can do it via terminal by running the following commands.

Deleting your credentials via the command line

Through the command line, you can use the credential helper directly to erase the keychain entry.

To do this, type the following command:

git credential-osxkeychain erase
host=github.com
protocol=https

# [Now Press Return]

If it's successful, nothing will print out. To test that it works, try and clone a repository from GitHub or run your previous action again like in my case git push. If you are prompted for a password, the keychain entry was deleted.


In case you get this error message in this situation:

  • using github for entreprise
  • using credential.helper=wincred in git config
  • using your windows credentials which you changed recently

Then look at this answer: https://stackoverflow.com/a/39608906/521257

Windows stores credentials in a credentials manager, clear it or update it.


This solution worked for me:

  1. open Control Panel
  2. Go to Credential Manager
  3. Click Window Credentials
  4. In Generic Credential section ,there would be git url, update username and password
  5. Restart Git Bash and try for clone

If you have just enabled 2FA :

Modify hidden config file in ./git hidden folder as follow :

[remote "origin"]
    url = https://username:[email protected]/project/project.git

Solution steps:

  1. Control Panel
  2. Credential Manager
  3. Click Window Credentials
  4. In Generic Credential section ,there would be git url, update username and password
  5. Restart Git Bash and try for clone

  1. Control panel
  2. Credential manager
  3. Look for options webcredentials and windows credentials
  4. in either one you will find github credentials fix it with correct credentials
  5. open new instance of git bash you should be able to perform your git commands.

This worked for me, I was able to pull and push into my remote repo.


Just Try this:

# git remote set-url origin [email protected]:username/repository

Hope this help


That problem happens sometimes due to wrong password. Please check if you are linked with AD password (Active Directory Password) and you recently changed you AD password but still trying git command with old password or not.

Update old AD password

Control Panel > Credential Manager > Windows Credential > change github password with my new AD password