TFS(Visual Studio Team Services) / Azure Devops git認證失敗 authentication fails 的解決方案 http協議


問題描述

TFS 的git倉儲地址使用http協議時,在visual studio中使用正常,可是git pull運行失敗,提示 authentication fails。
初步判斷原因為默認的 credential.helper 與 TFS 不兼容導致。
TFS 2015 與 Azure Devops(TFS 2019)都有這個問題。TFS2019建議使用ssh認證方式繞過這個問題,這樣也更加安全。

解決方法

使用管理員身份運行 git-bash / cmd / powershell 執行以下指令

git config --system credential.helper wincred

再次執行git pull,依照提示輸入正確的賬號密碼即可。

管理憑證可打開:windows控制面板-用戶賬戶-憑據管理器-Windows憑據-普通憑據。如果存儲的憑據有誤,可修改或刪除錯誤的憑據。

進階配置詳解

有關credential helper for windows的詳細內容:https://github.com/Microsoft/Git-Credential-Manager-for-Windows
git使用credential.helper來存儲憑證。默認為manager(system級別)。在安裝git時,會默認安裝 credential.helper。

查看系統支持的credential.helper

git help -a | grep credential-

查看已保存的相關設置

git config --global -l | grep credential.helper
git config --system -l | grep credential.helper

去除credential.helper 設置,system級別需要管理員權限,system級別的配置會覆蓋global級別的設置。

git config --system --unset credential.helper 
git config --global --unset credential.helper 

清除保存的憑證 https://stackoverflow.com/questions/15381198/remove-credentials-from-git

git credential-manager clear

Linux系統環境,可設置credential.helper為store

使用store會將密碼明文存儲,查看或修改已存儲的密碼可編輯配置文件 ~\.git-credentials


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM