[英]Working with git behind proxy
我在代理人后面。 為了讓git
工作,我必須添加
proxy = http://username:password@proxy.at.your.org:8080
到.gitconfig
。
由於username
和password
是我的系統憑證,這個解決方案很糟糕,因為我必須將它們存儲為cleartext
。
我正在使用Google Chrome
,因為它使用系統代理設置,因此我無需設置任何代理設置。
用git
怎么做?
2016年2月更新:
使用git 2。8(2016年3月),您無需在網址中以明文形式嵌入密碼。
請參閱Knut Franke的 提交372370f , 提交ef97639 (2016年1月26日) (``) 。
幫助: Junio C gitster
( gitster
) , Eric Sunshine( sunshinebell28
)和Elia Pinto( devzero2000
) 。
(由Junio C gitster
合並- gitster
- in commit 30f302f ,2016年2月3日)
http
:使用憑證API來處理代理身份驗證目前,將代理憑據傳遞給curl的唯一方法是將它們包含在代理URL中。 通常,這意味着它們將以未加密的方式結束在磁盤上(通過包含在
~/.gitconfig
,shell配置文件或歷史記錄中)。
由於代理身份驗證通常使用域用戶,因此憑據可能對安全性敏感; 因此,需要一種更安全的通過憑證的方式。如果配置的代理包含用戶名但不包含密碼,請查詢憑證API。 此外,請確保我們正確批准/拒絕代理憑據。 所以:
除了curl理解的語法之外,還可以指定具有用戶名但沒有密碼的代理字符串 ,在這種情況下,git將嘗試以與其他憑據相同的方式獲取一個代理字符串 。
有關更多信息,請參閱gitcredentials 。
語法因此是:
[protocol://][user[:password]@]proxyhost[:port]
這可以在每個遠程基礎上被覆蓋; 見
remote.<name>.proxy
。
2015年10月更新
從git 1.8.0和commit 7bcb747開始 ,默認的Windows憑據幫助程序是wincred
,它是一個與Windows的Credential Manager連接的git憑證幫助程序。
git config --global credential.helper wincred
原始答案(2013年3月):
您可以在Windows上使用git-credential-winstore等憑據幫助程序(git1.7.9 +)來存儲憑據。
您將使用' git config --global credential.helper winstore
'聲明它。
然后,您可以在不輸入用戶名和密碼的情況下聲明代理:
git config --global http.proxy http://proxy.server.com:8080
(雖然我更喜歡使用環境變量http_proxy
和https_proxy
)
另請參閱“ git:' credential-cache
'不是git命令 ”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.