简体   繁体   中英

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)

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://username@github.com | git credential reject

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

$ echo url=https://username@github.com | 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM