Skip to content

Instantly share code, notes, and snippets.

@ShenTengTu
Created May 29, 2019 04:40
Show Gist options
  • Save ShenTengTu/c9fafa692d63321f5c89bf22bc6087e6 to your computer and use it in GitHub Desktop.
Save ShenTengTu/c9fafa692d63321f5c89bf22bc6087e6 to your computer and use it in GitHub Desktop.
[Powershell] Add Git Submodule from .gitmodules
Write-Host "[Add Git Submodule from .gitmodules]" -ForegroundColor Green
Write-Host "... Dump git_add_submodule.temp ..." -ForegroundColor DarkGray
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > git_add_submodule.temp
Get-content git_add_submodule.temp | ForEach-Object {
try {
$path_key, $path = $_.split(" ")
$url_key = "$path_key" -replace "\.path",".url"
$url= git config -f .gitmodules --get "$url_key"
Write-Host "$url --> $path" -ForegroundColor DarkCyan
git submodule add $url $path
} catch {
Write-Host $_.Exception.Message -ForegroundColor Red
continue
}
}
Write-Host "... Remove git_add_submodule.temp ..." -ForegroundColor DarkGray
Remove-Item git_add_submodule.temp
@ShenTengTu
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment