Git sees the system profile as home instead of the user home folder (Windows 7)

Viewed 2876

I am new to Git and am following this Bitbucket tutorial for initial setup. In the Git Bash window, it shows me as brnt@brntslaptop, but if I enter

ls -a ~/.ssh

I get this output:

ls: /c/windows/system32/config/systemprofile/.ssh: No such file or directory.

I assume it has something to do with me being an administrator or having UAC disabled, but I am not sure of the best way to proceed.

This answer is similar- but I don't think it is a good idea to redirect from the system folder to a user folder, especially if another user has the same issue. Other similar answers seem to do a symbolic link or similar for a solution. But I haven't found one that involved the system profile.

I also considered changing the shortcut properties "Start In:" from %HOME% to %USERPROFILE%, but ~ still seems to resolve to %HOME%.

Is this behavior normal? What is the proper way to make "~" or %HOME% resolve to my user directory?

2 Answers

I landed here looking for a reason why on the same Windows machine, one user could use

git config --list --global

from the Windows-PowerShell commandline, but another user could not.

Basically, there is an automatic variable, $HOME, set in PowerShell pointing to the correct location; however this is not the variable git.exe is looking for. It wants the environment variable, $env:HOME, to be set.

In order to resolve it going forward, on the user who was not able to list their global settings we ran the following Windows-PowerShell command:

[System.Environment]::SetEnvironmentVariable('HOME',$env:USERPROFILE,'User')

Note: Here I've used the 'User' scope instead of the 'Machine' scope as shown in the documentation, because this typically does not require admin rights.

Related