1

Some context: trying to clone a repo with ssh url from git BASH, but getting the following error:

Could not create directory '/c/Usersusername/.ssh'
The authenticity of host '...' can't be established.

Why are the Users and username subdirectories getting concatenated? Is this expected? I'm assuming this is causing the error and the failed clone request.

From git BASH:

$ echo $HOME
/c/Usersusername

From Windows cmd:

C:\ echo %HOME%
C:/Users/username

I've tried $ setx home "C:/Users/username" .

Conner M.
  • 1,954
  • 3
  • 19
  • 29
  • Looks like the forward and back slashes are interpreted differently by BASH, with the later being an escape character. The difference is further complicated by the use of single or double quotes. https://stackoverflow.com/questions/40396613/forward-slash-vs-backward-slash-for-file-path-in-git-bash – Conner M. Jun 28 '21 at 16:51
  • `echo $HOME` can be misleading for any of [several reasons](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else). What does `printf "'%s'\n" "$HOME"` show? – Gordon Davisson Jun 28 '21 at 20:06

1 Answers1

0

Try and not set HOME: by default, git bash should use %USERPROFILE%

Try also to create in advance the .ssh folder, before using your SSH URL for cloning: that way, Git should directly go to the Host verification step, without failing on that folder creation.

Note: On Windows 10, with Git 2.32 for Windows, I do have a HOME set using C:\... backslash path, and it is correctly displayed as /c/... in a bash session without me setting it in .bashrc or .profile.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250