Reputation: 93
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?
Upvotes: 9
Views: 3570
Reputation: 2050
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.
Upvotes: 0
Reputation: 1371
Just change %HOME% (or actually $HOME, as %HOME% most likely is not set at all).
By default, <git-install-dir>\etc\profile
sets $HOME to %HOMEDRIVE%%HOMEPATH% if they are set and point to an existing directory, or to %USERPROFILE% otherwise.
So, you could edit that file, locate the line
HOME="$HOMEDRIVE$HOMEPATH"
and remove it or add an #
in front of it to force %USERPROFILE% to be used instead.
Alternatively, add a line anywhere after this block explicitly setting HOME to what you want it to be.
In newer versions of Git that line may no longer be present.
I have added the following at the very top of my etc\profile
(it is very specific and ugly, but it works):
# Homefix start
HOME=/c/Users/myusername/
HISTFILE=$HOME/.bash_history
export LANG=en_US
# Normalize HOME to Unix path
export HOME="$(cd "$HOME" ; pwd)"
# Homefix end
The export LANG...
line can be ignored. I have it there to get English text in menus and buttons in Git GUI and gitk, because IMO to translate Git commands adds no value, only confusion.
Upvotes: 3