中文字幕精品亚洲无线码二区,国产黄a三级三级三级看三级,亚洲七七久久桃花影院,丰满少妇被猛烈进入,国产小视频在线观看网站

Loading

Git 免(mian)密認證(zheng):Git Credential Helper

提到 Git 免密(mi),也許大(da)多數人會(hui)想到 SSH。但是(shi)當(dang) SSH 不可用的時(shi)候怎么(me)辦?

比如你沒有(you)提交 SSH 公(gong)鑰的(de)權限(xian)。

又比如自建(jian)的 Git,如果所(suo)有域(yu)名都在 Cloudflare 的保護下,不(bu)想暴露 ip 地址,就只能用 https。(PS: 這種情況也可以用 Cloudflare Tunnel,而且需要客戶端額(e)外(wai)配置,不(bu)是很推薦(jian))

Git Credential Helper

Git Credential Helper 就是解決在 HTTPS 協議(yi)下 Git 操作(zuo)時需要頻繁輸入密碼或者 PAT 的痛點。

設置僅需一行代碼:

git config --global credential.helper <helper_name>

macOS

git config --global credential.helper osxkeychain

Windows

新版的 Windows Git 應(ying)該,無需單獨設置。

git config --global credential.helper manager
# 或者
git config --global credential.helper wincred

Linux

如果有(you)桌面環境(jing),可以存到GNOME Keyring 或者 KDE Wallet

git config --global credential.helper libsecret

如果沒有,可以看下面的

通用方法

  1. Cache

    默認在內存中持續(xu)15分鐘,如果有需要(yao)可以(yi)延長時間。

    git config --global credential.helper cache
    # 一小時
    git config --global credential.helper 'cache --timeout=3600'
    
  2. Store

    這種方法不(bu)安全,因為(wei)是明文存(cun)儲,不(bu)要在公共環(huan)境(jing)或者生產(chan)環(huan)境(jing)使(shi)用,僅作為(wei)最(zui)后的手段(duan)。

    git config --global credential.helper store
    # 或者指定位置
    git config --global credential.helper 'store --file ~/.my-credentials'
    
  3. GCM: Git Credential Manager

    安裝方法見:

    只(zhi)要安裝,無需配置即可使(shi)用。

    對于Windows 用戶來說,只要安裝了 GCM,所有的 WSL 均(jun)可分享憑證,很方便。

參考資料:

posted @ 2025-10-29 15:15  SmileMachine  閱讀(158)  評論(0)    收藏  舉報