2

I'm trying to push my gist to github and trying to do it the right way by using the credential manager as per this answer

I assumed following simple workflow would suffice

  • clone a gist
  • pushing would ask credentials (username/token)

Unfortunately, it's either not that simple or I messed up somewhere else. All I get is a remote: Repository not found.


Cloning my gist

C:\Users\lieve\AppData\Local\Temp>git clone https://gist.github.com/lkeersmaekers/4884d047b3b90ccd697a4d7ec21be49d
Cloning into '4884d047b3b90ccd697a4d7ec21be49d'...
remote: Enumerating objects: 9, done.
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 9
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (2/2), done.

Show remotes

C:\Users\lieve\AppData\Local\Temp>cd 4884d047b3b90ccd697a4d7ec21be49d
C:\Users\lieve\AppData\Local\Temp\4884d047b3b90ccd697a4d7ec21be49d>git remote -v
origin  https://gist.github.com/lkeersmaekers/4884d047b3b90ccd697a4d7ec21be49d (fetch)
origin  https://gist.github.com/lkeersmaekers/4884d047b3b90ccd697a4d7ec21be49d (push)

Try to push fails and doesn't ask any credential

C:\Users\lieve\AppData\Local\Temp\4884d047b3b90ccd697a4d7ec21be49d>git push
remote: Repository not found.
fatal: repository 'https://gist.github.com/lkeersmaekers/4884d047b3b90ccd697a4d7ec21be49d/' not found

Credential manager diagnosis C:\Users\lieve\AppData\Local\Temp\4884d047b3b90ccd697a4d7ec21be49d>git credential-manager-core diagnose Running diagnostics...

 [ OK ] Environment
 [ OK ] File system
 [ OK ] Networking
 [ OK ] Git
 [ OK ] Credential storage
 [ OK ] Microsoft authentication (AAD/MSA)
 [ OK ] GitHub API

Diagnostic summary: 7 passed, 0 skipped, 0 failed.

I can get push to work by changing the remote to https://<token>@gist.github.com/lkeersmaekers/4884d047b3b90ccd697a4d7ec21be49d but that's exactly what the credential manager should take care of?

sytech
  • 29,298
  • 3
  • 45
  • 86
Lieven Keersmaekers
  • 57,207
  • 13
  • 112
  • 146

1 Answers1

1

The Git Credential Manager (GCM) (previously GCM-core, recently renamed as GCM) depends on the Windows Credential Manager.

Open said Windows Credential Manager and check if there is any github.com entry, which might include the wrong password (like your actual password instead of a token).

Delete that entry, and the next git push would ask for your credentials (do use the token as password then).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you, removing the existing github credential worked. Pushing asked for credentials *(the options provided in the dialogbox are not at all intuitive to me... got it to work by canceling the dialog box so the cli asked a username/password (token).* – Lieven Keersmaekers Dec 19 '21 at 09:56
  • I now have a user/token in credman *intended for that one gist*. It seems that every other repo I have now uses that credential when pushing (and failing). That means I was totally wrong in creating a PAT per repo? Can there be only one PAT per user/machine? – Lieven Keersmaekers Dec 19 '21 at 10:01
  • @Lie one PAT, with scope repo, should be enough. – VonC Dec 19 '21 at 11:39