Git sees the system profile as the user's home rather than the user's home folder (Windows 7)

I am new to git and after this bitbucket tutorial for initial setup. In the git bash window, it displays me as brnt @brntslaptop, but if I type:

$ ls -a ~/.ssh ls: /c/windows/system32/config/systemprofile/.ssh: No such file or directory. 

I assume this is because I am an administrator or disabled by UAC, but I am not sure of the best way to proceed.

This answer is similar - but I don’t think it’s a good idea to redirect from the system folder to the user folder, especially if the other user has the same release. Other similar answers seem to make a symlink or similar for the solution. But I did not find what is connected with the system profile.

I also looked at changing the properties of the Start at: shortcut from% HOME% to% USERPROFILE%, but ~ still seems to allow% HOME%

Is this normal behavior? How can I enable "~" or% HOME% for my user directory?

+4
source share
1 answer

Just change% HOME% (or actually $ HOME, since% HOME% is most likely not configured at all).
By default, <git-install-dir>\etc\profile sets $ HOME to% HOMEDRIVE %% HOMEPATH% if they are installed and point to an existing directory, or to% USERPROFILE% otherwise.

So you can edit this file, find the line

 HOME="$HOMEDRIVE$HOMEPATH" 

and delete it or add # in front of it to use% USERPROFILE% instead.

Alternatively, add a line somewhere after this block, explicitly setting HOME the way you want.

EDIT:
In newer versions of git, this line can no longer be present. I added the following at the very top of my etc\profile (this 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 line export LANG... can be ignored. I have this to get English text in menus and buttons in git gui and gitk, because IMO for translating git commands does not add value, just confusion.

+1
source

All Articles