Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
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 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 symlink 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?

like image 314
brnt Avatar asked Aug 06 '12 17:08

brnt


1 Answers

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.

EDIT:
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.

like image 104
Superole Avatar answered Sep 30 '22 16:09

Superole