Last active
August 6, 2020 08:50
-
-
Save jetersen/e3cfd41dc9053cab4ab9bad4ffae8fc8 to your computer and use it in GitHub Desktop.
Change git remote username directly in git config file
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
$gitConfigs = Get-ChildItem "C:\git\code" -Include config -File -Recurse -Force | Where-Object { $_.FullName -match "\.git\\config" } | |
$count = $gitConfigs.Count | |
for ($i = 0; $i -lt $count; $i++) { | |
$config = $gitConfigs[$i] | |
$content = Get-Content $config | |
if (($content | ForEach-Object { $_ -match 'casz/|Jetersen/'}) -contains $true) { | |
$content | ` | |
ForEach-Object { $_ -ireplace 'casz/','jetersen/' -replace 'Jetersen/','jetersen/' } | ` | |
Set-Content -Path $config | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment