Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Personal Access Token in Github not working

I have a private repository on my personal Github account that I work on from time to time, but not on a daily basis.

The repository has been cloned using HTTPS (not SSH or git://). In order to access the repository from the command line, I set up a personal access token as explained here: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

I am positive it did work back then (I moved away from SSH precisely because this kind of persistent headache).

However, when I try to push to my repository after a few weeks I get the dreaded:

$ remote: Repository not found. fatal: repository
$ 'https://github.com/nicolas-miari/MyPrivateRepo.git/' not found

What am I missing?


Addendum: I deleted the token on Github, created a new one, and followed the instructions here: https://help.github.com/articles/updating-credentials-from-the-osx-keychain/ to clear the old token stored in the keychain. I was able to re-clone my private repository. However,

  1. This still doesn't explain why the previous access token suddenly stopped working, and

  2. My keychain had two "Internet password" entries matching the host github.com: The access token I just deleted, and the my web login password for a different Github account (work). Maybe this has something to do with it?

Background info: To avoid having to log in/out frequently, I have my work account's web credentials saved in Safari (and the Keychain), and my personal account's web credentials saved in Firefox.


Addendum 2: After running the command given on the linked help page:

$ git credential-osxkeychain erase
  host=github.com
  protocol=https
  [enter]

...the additional password is gone from the Keychain (only my newly added Personal Token remains), however I can still log in to my account on Safari...?


Update: Now I can't push to repos from my work account (which credentials I deleted from Keychain...). This system really needs a healthy dose of Just Works...

like image 927
Nicolas Miari Avatar asked Jun 07 '17 05:06

Nicolas Miari


2 Answers

I have a private repository that I have a dependency on, using https://github.com... in my package.json. I have ssh set up on my computer, also I have personal access token. Even though I provide my personal access token as the password it fails. So I changed my git config url using the following and it worked like a charm.

git config --global url."[email protected]:".insteadOf "https://github.com/"

You can double check your ~/.gitconfig to see something like this:

[url "[email protected]:"]
    insteadOf = https://github.com/
like image 65
FullStackEngineer Avatar answered Sep 19 '22 21:09

FullStackEngineer


I tried all the suggestions I could find and the only thing that worked for me was deleting Git on my computer. Once I downloading it again it asked me to to login with browser, which I did and then it worked

like image 35
LaurentBaj Avatar answered Sep 19 '22 21:09

LaurentBaj