Git config alias doesn't work anymore

梦想的初衷 提交于 2019-12-06 03:54:51

问题


I used command:

git config --global alias.st status

to add my first alias as suggested by post - How do I alias commands in git?

Then, I found it being added to config file at:

C:\Users\damodar.bashyal\.gitconfig

So, i added bunch of aliases directly on the config file and all worked perfectly until today when I had to restart my computer after installing MYOB software.

When i tried to use alias none worked. So, i added another alias using above command, but the file didn't get updated but new alias worked fine.

So after struggling for a while found a command at [ Where does git config --global get written to? ] to look for the config file:

git config --global --edit

To my surprise, it was showing different location with new git alias added in it.

.gitconfig(~) - VIM

[gui]
   recentrepo = C:/_projects/example.com/trunk/bitbucket
[user]
   name = damu
[alias]
   st = status

Is there a way to change back path to previous .gitconfig file?

I am using windows 7 and msysgit.

c:\>echo %HOME%
%HOME%

c:\>set HOME
HOMEDRIVE=U:
HOMEPATH=\
HOMESHARE=\\agsbs\UserShares\Damodar.Bashyal

c:\>echo %HOME%
%HOME%

UPDATE: followed this post [ Change User location(home variable) in Egit (Eclipse) ] to set missing HOME environment variable and now i am getting this:

c:\>set HOME
HOME=C:\Users\damodar.bashyal
HOMEDRIVE=U:
HOMEPATH=\
HOMESHARE=\\agsbs\UserShares\Damodar.Bashyal

That also fixed my issue. YAY!!!


回答1:


Check what your HOME references:

echo %HOME%
# or
set HOME

git config --global will reference the HOME path (unless you would use the --file option).
HOME isn't defined by default on Windows, but it is set by the git-cmd.bat script included with msysgit.

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%


来源:https://stackoverflow.com/questions/13150031/git-config-alias-doesnt-work-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!