Pushing to Github with a Token

Hello,

I have a project I built that i’m trying to push up. Normally I would complete a project and push to it using these commands:

git remote add origin GitHub - Brixsta/mylist
git branch -M main
git push -u origin main

However, now Github requires a token. All the documentation I’ve read says that if you type ‘git push’ you will be prompted for a username and password. The password being the token that you created. However, I am never prompted to enter a username and password. Additionally, most examples of token authentication seem to be for cloning a repo. I’m pushing an existing project to a repo.

Anyone know how to push an existing project to a repo that satisfies token authentication? Thanks

This is probably because your Git credentials are being cached by the credentials manager. You need to delete the old account and password so that Git can prompt you again for it, give it the PAT instead, and from then on it will be stored. Depending on which Git apps you’re using, this step might need to be repeated for each and every app that access Git, in case they store credentials elsewhere.

2 Likes

Thank you. Once I deleted my github credentials from Keychain I was prompted for the username and password. Password was the token, thank you.

2 Likes

Can I further the question? How does one actually delete the credentials to reprompt the username and token? I can’t seem to do it correctly to where the prompting works to enable me to push again to my existing repos! TYIA

Unfortunately this depends on the credential manager you’re using, which might differ from one OS to another, and whether you’re using Git’s native manager or a third party manager (your OS’s native manager, or another one). You should query Git’s options to see what manager Git is using, via:

$ git config --global credential.helper cache

https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage

1 Like

ok so I have windows, used the credential manager to delete all github crdentials I saw…
but
git add . still doesnt do anything and when i attempt a push i get this error message

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see Token authentication requirements for Git operations | The GitHub Blog for more information.
fatal: Authentication failed for ‘https://github.com/USERNAME/repo.git/

even when i put in my PAT… not sure what im doing wrong

TY!

NVM I got it… I’m just kinda dumb and was looking at the wrong folder :woozy_face:

Then you’re probably using the Git Credential Manager for Windows.

Strange, if you’ve deleted your previous credentials you should be asked for USER and PASSWORD again, where you will need to add your GH USERNAME and your PAT (instead of the password).

Under Windows, you can access the list of credentials via Control Panel » Credential Manager (just type “Credential Manager” in the Start menu). You should see all the credentials for the various repositories. You should see detailed info on each repository and account, as well as being able to edit or delete previously stored credentials.

Beware that you might have set some credentials globally, and others on a per-repository basis.

For more info, see this article:

https://treehozz.com/where-is-git-password-stored

Welcome to the community, @Brixsta! If @tajmone’s solution helped, kindly mark it as a solution so that it can help others who may face this same issue.

And thanks, @tajmone for quickly jumping in and assisting. :smiley_cat: