V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
FaiChou
V2EX  ›  程序员

GitHub 总是掉授权,电脑记不住 token

  •  
  •   FaiChou ·
    FaiChou · 293 天前 · 1978 次点击
    这是一个创建于 293 天前的主题,其中的信息可能已经有所发展或是发生改变。

    由于 GitHub 已经关闭了 https 的账号密码形式的验证,现在只能通过生成 token 的形式来当密码。

    When Git prompts you for your password, enter your personal access token.

    但电脑老是记不住这个 token ,下次 git fetch 还是会弹用户名和密码。

    我两台电脑,MBA 没问题,出问题的是新的 mac mini ,而且 mini 之前是没问题的,前几天刚出变成这样。

    在 keychain access 中查看 github 类型为 Internet password 的记录,在 Mac mini 上是没有的。

    所以不知道是什么情况。

    有没有遇到的小伙伴?应该怎么解决?

    9 条回复    2023-07-10 12:18:38 +08:00
    GeruzoniAnsasu
        1
    GeruzoniAnsasu  
       293 天前
    https://sheepblackish.medium.com/set-up-git-credentials-on-mac-os-with-private-key-github-access-token-8bf7b79e91d4

    不过我基本不用 HTTPS ,用 SSH

    SSH 协议用的是我的 gpg 公钥来验证,gpg suite ( gpg keychain )向我询问一次私钥保护密码后就一直 cache 了
    FaiChou
        2
    FaiChou  
    OP
       293 天前
    @GeruzoniAnsasu 看来以后要都换成 ssh 了 没那么多问题了。
    codehz
        3
    codehz  
       293 天前
    下载一个 github desktop 登录吧(
    或者用 github cli 也可以
    (会帮你配制好本地的 git 的
    Explr
        4
    Explr  
       293 天前 via Android
    试试换个 credential helper ?比如 manager-core 或者 manager ?

    https://git-scm.com/docs/gitcredentials

    https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
    thinkershare
        5
    thinkershare  
       293 天前
    应该是系统的密钥凭证管理有问题,或者 github 没有在 mac mini 上正确使用凭证管理,如果你能够确保你的系统是安全的话,可用这样做, 这两种模式的缺点是别人通过 git remote 或者查看你的 git config 文件能够盗取你的凭证。
    git clone https://[email protected]/$user/$repository.git
    git clone https://oauth2:[email protected]/$user/$repository.git
    julyclyde
        6
    julyclyde  
       293 天前
    如果你定位到是 keychain 的问题,你看看那个记录是否在 icloud chain 里?
    mohumohu
        7
    mohumohu  
       293 天前
    Github Desktop 一键
    wxxxcxx
        8
    wxxxcxx  
       293 天前
    装一个 github 的 cli 客户端,然后

    ```
    gh auth login
    ```

    然后 git 用 https 就行了,我一直这么操作的。
    blankmiss
        9
    blankmiss  
       292 天前
    或者用 ssh 认证
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2744 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:22 · PVG 23:22 · LAX 08:22 · JFK 11:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.