Created
May 29, 2019 04:40
-
-
Save ShenTengTu/c9fafa692d63321f5c89bf22bc6087e6 to your computer and use it in GitHub Desktop.
[Powershell] Add Git Submodule from .gitmodules
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference : Restore git submodules from .gitmodules @ Stack Overflow