无法设置GitHub访问令牌



当我尝试使用HTTPS对任何存储库进行git克隆时,它不会提示我输入访问令牌,我只收到403错误。使用SSH的git克隆确实可以正常工作。我怀疑这个问题与使用ZScaler的公司笔记本电脑有关,HTTPS信任\证书链已断开
git如何像浏览器一样知道要使用什么证书?或者如何解决此问题?

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
Cloning into 'python-docs-samples'...
fatal: unable to access 'https://github.com/GoogleCloudPlatform/python-docs-samples.git/': The requested URL returned error: 403

我已经尝试从我的KeyChain中删除所有引用,这样它会再次提示我输入我的访问令牌,但从来没有。此外,我在OSX KeyChain 中看不到任何对git的引用

我的本地git被设置为使用osx KeyChain

$ git config --get-all --show-origin credential.helper
file:/Applications/Xcode-11.3.1.app/Contents/Developer/usr/share/git-core/gitconfig     osxkeychain

但它似乎知道我在公司GitHub 的GitHub证书

$ git credential-osxkeychain get
password=<my company password>
username=<my company logon>

git从哪里获得我公司GitHub的用户名和密码,以及我如何告诉git使用我的凭据&GitHub.com的访问令牌?

更新1

$ git credential-cache exit
$ git credential-osxkeychain erase
host=github.com
protocol=https
$ git config --global --unset credential.helper

现在这个命令不返回

$ git credential-osxkeychain get

但是仍然得到403错误,即使按照下面的建议使用我的GitHub用户名,它也不会提示我。
我已经仔细检查了我的KeyChain,那里没有存储任何GitHub

一个很好的提示,可以促使凭据帮助者用正确的登录名询问您的凭据,那就是将所述登录名添加到您的GitHub URL:

git clone https://<MyGitHubAccount>@github.com/GoogleCloudPlatform/python-docs-samples.git

并确保您已从OSX Keychain 中删除任何GitHub条目

然后它应该提示您输入密码。

终于找到了的解决方案

$ git config --global url.git://github.com.insteadOf "https://github.com"

这强制公共github站点在没有身份验证的情况下使用git协议,同时仍在公司网络和我们的私有github存储库中工作

最新更新