5

I have followed the explanation here for setting up auto authentication of github on my CLI (on Linux, Ubuntu). In particular, I executed the command given here:

gh auth login

And then I answered Github.com, yes, HTTPS, and my authentication token to the prompts.

This seems to work: It states "Configured git protocol" and "Logged in as ...".

However, when I then write git clone <myrepo>, it asks me again for my username and password.

What am I doing wrong? My understanding was that the gh aut login command is supposed to prevent me from having to type the login data each time.

user56834
  • 244
  • 4
  • 19
  • @dan1st, I understand that, but the site I linked to states "GitHub CLI will automatically store your Git credentials for you when you choose HTTPS as your preferred protocol for Git operations". Therefore I am assuming that gh is doing some configuration of git behind the scenes, at least if it's working properly. If not, what should I do to log in? – user56834 Dec 11 '21 at 10:04
  • @dan1st, also note that the title of that page is ""Caching your GitHub credentials in Git.", and the motivation is: "Instead of manually entering your PAT for every HTTPS Git operation, you can cache your PAT with a Git client." – user56834 Dec 11 '21 at 10:05

2 Answers2

14

found in the Github CLI Docs:

after you run gh auth login then run this command

gh auth setup-git
synthmusic
  • 301
  • 3
  • 5
7

In my case it was solved by adding at the end of the file ~/.gitconfig the following:

[credential "https://github.com"]
    helper = 
    helper = !/snap/bin/gh auth git-credential

Modify /snap/bin/gh with your real path (I've seen others having it in /usr/bin/gh)

Marc
  • 71
  • 1
  • 2