Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Git accessing my GitHub credentials?

I have attempted to remove Git's access to private GitHub repositories on GitHub. No matter what I try, I cannot stop it from gaining access. I therefore wish to know how it is authenticating, so I can remove access.

I have tried both methods here

First:

git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper

and second

git config --global --unset-all

And I've also deleted every github entry in Keychain Access.

When I open a new terminal window, and push to a private GitHub repository, it asks for by username and email (not password), yet the push succeeds.

Question

How can I find out how Git in terminal able to use my GitHub credentials to push a change to GitHub?

Notes

  • I'm connecting to GitHub via HTTPS (rather than SSH)
like image 835
stevec Avatar asked Mar 20 '26 05:03

stevec


2 Answers

Per the GitHub Docs, for macOS:

Through the command line, you can use the credential helper directly to erase the keychain entry.

$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]

If it's successful, nothing will print out. To test that it works, try and clone a private repository from GitHub. If you are prompted for a password, the keychain entry was deleted.

like image 101
Skurhse Avatar answered Mar 23 '26 01:03

Skurhse


On most macOS systems, the credential.helper variable is not set in the global config, but in the system one, so you still have a credential helper enabled. You can verify this by running git config --get credential.helper, which will probably print osxkeychain.

If your goal is to remove the credentials, you can do that by following the steps outlined in the Git FAQ:

$ echo url=https://[email protected] | git credential reject

If you're just interested in whether the credential helper has any credentials, you can run this:

$ echo url=https://[email protected] | git credential fill | less

That will print a line containing password= with the password. Note that in this case I've piped it to less to prevent it from being printed long-term on the screen.

like image 39
bk2204 Avatar answered Mar 22 '26 23:03

bk2204



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!