Reputation: 18780
Even if I set the HOME environment variable explicitly, git bash insists in launching with default folder HOMEDRIVE/HOMEPATH which is a network folder.
Is there a way to override this behavior?
Upvotes: 1
Views: 242
Reputation: 1326776
I just checked with git version 2.47.1.windows.1.
My shortcut still has %HOMEDRIVE%%HOMEPATH%
in the 'Start in
' field:
And yet, when it executes "C:\Program Files\Git\git-bash.exe" --cd-to-home
, the pwd
is my %HOME
% folder, not %HOMEDRIVE%%HOMEPATH%
Git 2.48 (Q1 2025), pre-2.48-rc1 confirms the default value for %HOME%
.
See commit 8525e92 (09 Dec 2024) by Alejandro Barreto (alejandro5042
).
(Merged by Junio C Hamano -- gitster
-- in commit 930f2b4, 19 Dec 2024)
8525e92886
:Document HOME environment variableSigned-off-by: Alejandro Barreto
Signed-off-by: M Hickford
Git documentation refers to
$HOME
and$XDG_CONFIG_HOME
often, but does not specify how or where these values come from on Windows where neither is set by default.
The new documentation reflects the behavior ofsetup_windows_environment()
incompat/mingw.c
.
git
now includes in its man page:
HOME
Specifies the path to the user's home directory.
On Windows, if unset, Git will set a process environment variable equal to:
$HOMEDRIVE$HOMEPATH
if both$HOMEDRIVE
and$HOMEPATH
exist;- otherwise
$USERPROFILE
if$USERPROFILE
exists.
But since, in my case, I have set the HOME
environment variable explicitly, I can confirm the 2024 version of Git does respect it.
Upvotes: 0
Reputation: 18780
Figured it out
The issue was with the shortcut to Git Bash - "start in folder" set to %HOMEDRIVE%
...
Upvotes: 1