0

I have generated a new access token, and I tried to clone a repo but got that error: Github remote: Invalid username or password. fatal: Authentication failed I tried multiple trials, I set the github token as: git config --global github.token mytoken and I opened my .gitconfig file to check it and found it correctly:

[user]
    name = {github user}
    email = {github email}
[github]
    token = {new token}
    
[credential]
    helper = store
[core]
    editor = vim

I even tried git config --global --unset-all user.password and I was expecting that it will ask me for te username and password (in this case, I would add token), but it didn't ask about neither the username nor password, and still when I try cloning I get the same error.

Is there anything I am missing that would help or something I need to check please?

Mee
  • 1,145
  • 3
  • 15
  • 28
  • 1
    I don't think anything looks for a `github.token` setting. You're using `credential.helper = store` here so your https authentication user name and password are stored (unprotected!) in whatever file you specify, with the default being `~/.git-credentials`. You can edit this file with any editor (although you're not supposed to), or remove it. See [the documentation](https://git-scm.com/docs/git-credential-store). – torek Mar 24 '22 at 14:54
  • 1
    See also [this answer from VonC](https://stackoverflow.com/a/68374333/1256452). Related: [clear all git credentials from the CLI on git for windows' bash](https://stackoverflow.com/q/57981960/1256452). – torek Mar 24 '22 at 14:57
  • I already removed the file ```~/.git-credentials```, all these steps are after deletion of this file and still no luck – Mee Mar 24 '22 at 15:33
  • What OS are you on? You might want to use the osx keychain credential helper on OSX, or the Windows credential manager on Windows. Do you have any other credential helpers enabled? – torek Mar 24 '22 at 15:38
  • I am using windows – Mee Mar 24 '22 at 15:40
  • In that case, you probably want to see [Adding Git credentials on Windows](https://stackoverflow.com/q/46878457/1256452) and its linked questions. (I don't use Windows, and I don't use https if I can avoid it: I prefer ssh for connecting to GitHub.) – torek Mar 24 '22 at 15:42

2 Answers2

0

The issue was resolved by:

1- Control Panel

2-Credential Manager

3-Click Window Credentials

4- In Generic Credential section ,there would be git url, update username and password (in that case password is the new token)

5-Restart Git Bash and try for clone

Mee
  • 1,145
  • 3
  • 15
  • 28
-1

On my case I have uninstalled the source tree and reinstalled it. it's worked for me.

  • tanks for your comments, but can u please elaborate more? you mean uninstalling git as regular uninstalling from control panel? – Mee Mar 24 '22 at 09:59
  • I have uninstalled the source tree from the control penal and reinstalled it. – Ronak Panchal Mar 24 '22 at 10:01
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 24 '22 at 12:15