Created
February 26, 2021 08:17
-
-
Save alexmags/8f9e8bd86b6fdcf181389168831b8c2a to your computer and use it in GitHub Desktop.
Git client puts it's config in %homedrive%%homepath%. This is usual for Windows apps and breaks when homedrive disconnected. Use %appdata%\git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %homedrive%%homepath% is weird and breaks when homedrive disconnected. Use %appdata% | |
# https://git-scm.com/docs/git-config#git-config-XDGCONFIGHOMEgitconfig | |
$ConfigDefaultLocation="$($env:homedrive)$($env:homedrive)\.gitconfig" # breaks when network drive isn't connected | |
$ConfigBetterLocation="$($env:appdata)\git\config" # Standard location for app data that you want to follow user | |
[System.Environment]::SetEnvironmentVariable('XDG_CONFIG_HOME', "$($env:appdata)",[System.EnvironmentVariableTarget]::user) | |
$env:XDG_CONFIG_HOME=[System.Environment]::GetEnvironmentVariable("XDG_CONFIG_HOME","User") | |
# make better git data folder if not exists | |
New-Item -ItemType directory -Path "$($env:XDG_CONFIG_HOME)\git" -ErrorAction SilentlyContinue | out-null | |
# Move any existing git config from %homedrive%%homepath% to %appdata%\git | |
if (test-path -Path $ConfigDefaultLocation) | |
{ | |
Move-Item -Path $ConfigDefaultLocation -destinaion $ConfigBetterLocation -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment