2013-07-01 222 views
5

我想克隆一個倉庫,但我得到一個錯誤混帳克隆:無法創建目錄

Could not create directory '/c/Windows/system32/config/systemprofile/.ssh'. 
The authenticity of host '(host here)' can't be established. 

我運行Windows 7和使用tortoiseGit。 我已經生成了一個ssh密鑰並將其添加到服務器。 有什麼建議我做錯了什麼?

+0

您正在運行git作爲'SYSTEM'用戶。爲什麼? – Chronial

+0

嘗試運行一次有高架privs bash並從那裏克隆。當ssh要求鍵入yes來添加主機指紋時,此提示可能是部分內容 –

回答

6

恰好碰到了這個問題,並想後的解決方案。

當使用SSH的Cygwin的版本,你需要創建一個名爲HOME的環境變量。如果創建HOME作爲一個系統變量,並將其設置爲%USERPROFILE%和cmd/bash中被推出,系統(高架),您%HOME%道路將C:\Windows\System32

一個簡單的解決方法是硬編碼到HOME系統變量您USERPROFILE路徑C:\Users\username,但是如果你有,你需要創建相應的環境變量多個用戶。

我並沒有暗示推出CMD作爲SYSTEM但是我是有這個問題,不知道爲什麼。最安全的選擇是隻有一個用戶環境變量稱爲%USERPROFILE%和不使用提升的命令提示。

如果您遇到此問題,請運行ECHO %HOME%,您會看到變量正在被讀取的內容(或者是否存在)。

1

我用SSH克隆與Windows混帳回購協議;但是在PowerShell中。

$configStoreGitDir = "$GitBaseDir\.git" 
if (!(Test-Path -Path $configStoreGitDir -PathType Container)) { 
    Write-Verbose "Unable to locate local git folder at $GitBaseDir - recreating and cloning" 
    New-Item -Type Directory $GitBaseDir 
    git clone $GIT_REPO $GitBaseDir 
} 

當我試圖克隆回購,因爲我居然也得到了同樣的.ssh目錄錯誤用戶:

Cloning into 'C:\Git\test-environments'... 
Could not create directory '/c/Windows/system32/.ssh'. 

而不是硬編碼的路徑,我設置PowerShell的環境變量$env:USERPROFILE使用HOME就像他在答案中提到的@akevit一樣。

$env:HOME = $env:USERPROFILE 
$configStoreGitDir = "$GitBaseDir\.git" 
if (!(Test-Path -Path $configStoreGitDir -PathType Container)) { 
    Write-Verbose "Unable to locate local git folder at $GitBaseDir - recreating and cloning" 
    New-Item -Type Directory $GitBaseDir 
    git clone $GIT_REPO $GitBaseDir 
} 

現在它的工作原理和使用中的用戶$env:USERPROFILE\.ssh\目錄known_hostsid_rsa私鑰。

Cloning into 'C:\Git\test-environments'... 
remote: Counting objects: 460, done. 
remote: Compressing objects: 100% (457/457), done. 

這與最新的Windows 64安裝的git:

git --version 
git version 2.6.3.windows.1