0

As far as I know, when you use git with https, you would have to type in your password every time you make a request to github unless you use SSH or you store your credentials locally on your computer with git config credential.helper store .

I've been using HTTPS but never have to type in my credentials. When I run git config --list it only shows my email and my name, but not my password. Can anyone explain to me why I am not required to type in my password or where it could be stored?

Boris Grunwald
  • 2,602
  • 3
  • 20
  • 36
  • Is target repo private ? If not, it is normal to be able to `clone`, `fetch` and `pull` without credentials. They would be required to `push` – LeGEC Nov 01 '22 at 18:43
  • The credentials will not show up in `git config --list` (user.name and user.email are only used for commits' author and committer fields), they will show up in `git remote -v` (the url you use to access your remote, it will at least mention if you use a username when connecting to the remote) – LeGEC Nov 01 '22 at 19:33

1 Answers1

3

I've been using HTTPS but never have to type in my credentials.

That is probably because your credentials are already cached by a credential helper.

  1. Check what yours is: git config --global credential.helper
  2. Check what credentials are stored:

In a Git bash session:

printf "host=github.com\nprotocol=https" | git-credential-xxx get

Replace xxx by the value returned by git config --global credential.helper.

If it is empty, and if the remote URL is an HTTPS one, then, as suggested by LeGEC in the comments, Git might still be using SSH anyway with an url.<base>.pushInsteadOf directive.
Check that with:

git config --show-origin --list --show-scope | grep -i insteadOf

The OP adds in the comments:

running git config --show-origin --list gives me, among other things, file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig credential.helper=osxkeychain
So it could look like it is stored in my osxkeychain?

If that is the case:

printf "host=github.com\nprotocol=https" | git-credential-osxkeychain get

See also "Updating credentials from the macOS Keychain".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hm `git config --global credential.helper` doesn't return anything (running it on my MacBook Air M1) – Boris Grunwald Nov 01 '22 at 19:20
  • @BorisGrunwald What is the remote URL of your local repository? (`git remote -v` inside the repo folder) – VonC Nov 01 '22 at 19:39
  • `origin https://github.com/jikol1906/sentence-guesser-react.git (fetch) origin https://github.com/jikol1906/sentence-guesser-react.git (push)` – Boris Grunwald Nov 01 '22 at 19:52
  • It is a private repo – Boris Grunwald Nov 01 '22 at 19:52
  • @BorisGrunwald Then you must enter your credentials on each push, no? – VonC Nov 01 '22 at 19:58
  • No I don't have to. Really have no idea what is going on. – Boris Grunwald Nov 01 '22 at 20:06
  • @BorisGrunwald Do you see your credentials in your environment variables (`env`)? Or in a `rc` files? (`.bashrc` or `.curlrc`) – VonC Nov 01 '22 at 21:53
  • @BorisGrunwald: `git config --show-origin --list | grep insteadOf` ? – LeGEC Nov 01 '22 at 22:05
  • @LeGEC running `git config --show-origin --list` gives me, among other things, `file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig credential.helper=osxkeychain` So it could look like it is stored in my osxkeychain? – Boris Grunwald Nov 01 '22 at 22:21
  • @BorisGrunwald True. I should have checked the other scopes. That is why I suggested in my edited answer `git config --show-origin --list --show-scope`. – VonC Nov 01 '22 at 22:23
  • 1
    @BorisGrunwald Of interest: "[`git-credential-osxkeychain` wants to access key "`github.com`" in your keychain](https://stackoverflow.com/q/68868084/6309)". – VonC Nov 01 '22 at 22:27