2011-04-26 70 views
10

我在Codaset上有一個私人git存儲庫。通常,當我嘗試通過Windows計算機上的HTTPS克隆它時,它會向我詢問我的用戶名和密碼。當我嘗試在Ubuntu服務器上克隆它時,它永遠不會要求我提供用戶名或密碼,並且會因401錯誤而失敗。我需要做什麼改變?git通過https 401錯誤克隆,而不是要求用戶名或密碼

下面是我在做什麼:

git clone https://codaset.com/username/project_name.git destination_folder_name.git 

回答

7

你可以這樣做:

git clone https://[email protected]/username/project_name.git destination_folder_name.git 

,使其提示密碼。

+0

這並使其提示我輸入密碼,但隨後還是失敗,錯誤502 – 2011-04-27 17:01:30

12

爲了避免在所有輸入密碼(在Windows或Unix),您可以:

  • 檢查,家是定義(在Windows上,它不是默認情況下)
  • 設置一個_netrc文件,內容如下:
 
    machine codaset.com 
    login your_codaset_login 
    password your_codaset_password 

注:%HOME%\_netrc在Windows上,$HOME/.netrc在Unix

這樣一來,當你克隆你的回購,而不是鍵入:

git clone https://[email protected]/username/project_name.git destination_folder_name.git 

,你可以刪除初始用戶名:

git clone https://codaset.com/username/project_name.git destination_folder_name.git 

,你將不必輸入密碼。


如果你不想把你的憑據(特別是您的密碼)在明文.netrc文件,你可以加密netrc文件,gpg:詳見「Is there a way to skip password typing when using https:// github

+0

這對我有用 – zhaozhi 2014-01-14 06:53:06

+0

@zhaozhi太棒了。如果您不希望密碼以純文本格式存儲在文件中,您甚至可以加密該「.netrc」文件:http://stackoverflow.com/a/18362082/6309 – VonC 2014-01-14 06:56:11

+0

+1加密。謝謝! – Dan 2014-10-21 13:17:01