1

I have entered the wrong password in git during cloning. Now, every time I want to clone the repository, git doesn't ask for the password from me and shows the error below:

remote: Invalid username or password

Could anyone tell me how can I reset the saved password?

9
  • 2
    git config --global --unset credential.helper Commented Mar 11, 2020 at 16:38
  • thanks for the response, but I have tried that before but it did not work. Commented Mar 11, 2020 at 16:40
  • Is the password cached globally, or on a single project? Try: ` git config --global --add user.password "newPass"` Commented Mar 11, 2020 at 16:43
  • it did not work again, again I got "remote: Invalid username or password " error. there is not any way to reset all settings of git? Commented Mar 11, 2020 at 16:49
  • 1
    You should replace newPass with your own password of course. Otherwise use git config --global --unset user.password to remove the users password (not from the helper) Commented Mar 11, 2020 at 16:59

1 Answer 1

1

I'm going to assume for the moment that you're using a credential helper. This is the reasonable and secure thing to do.

The easiest way to reset any credential helpers is to tell the credential helper that the password is bad and should be rejected. Normally this occurs when your password is bad anyway, but sometimes it doesn't. You can do this with the following (substituting origin if necessary):

$ echo "url=$(git remote get-url origin)" | git credential reject

If that doesn't work, you can also try to give the credential helper a hint by adding a username. For example, if I were trying to reset my GitHub credentials, I'd write the following:

$ echo url=https://[email protected] | git credential reject

Usually that should be sufficient. It is possible if you're using one of the Microsoft-built credential helpers that they don't honor that setting, but most of the standard ones on Linux should.

Note that there is no user.password config setting. The user group of configuration options is not used for remote servers, a secure configuration results in different passwords for different servers (which the hypothetical user.password would not), and storing secrets in the .git/config is not secure.

If none of these work, you'd need to inspect your Git configuration with git config -l. You'd be looking for a credential helper (credential.helper or credential.*.helper) or some other configuration that contains credentials. Since you haven't included that, we can't really tell you what might be going on.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.