Skip to content

Instantly share code, notes, and snippets.

@maoyeedy
Created February 23, 2026 18:40
Show Gist options
  • Select an option

  • Save maoyeedy/51abce4952b3f6bfb27ffb246c3e82be to your computer and use it in GitHub Desktop.

Select an option

Save maoyeedy/51abce4952b3f6bfb27ffb246c3e82be to your computer and use it in GitHub Desktop.
[CmdletBinding()]
param()
if (-not (Get-Command -Name 'Get-UnityVersion' -ErrorAction SilentlyContinue)) {
. "$PSScriptRoot\functions.ps1"
}
Write-Host "`nConfiguring Git submodules..." -ForegroundColor Yellow
try{
# git config submodule.recurse true
# git config fetch.recurseSubmodules true
# git config pull.recurseSubmodules true
$postMergeHookPath = ".git/hooks/post-merge"
$lineToAdd = @"
echo -e '\033[1;33mUpdating Submodules...\033[0m'
git submodule update --init --recursive
echo -e '\033[1;32mUpdate Complete\033[0m'
"@
if (Test-Path $postMergeHookPath) {
$content = Get-Content $postMergeHookPath
if ($content -notcontains 'git submodule update --init --recursive') {
Add-Content -Path $postMergeHookPath -Value "`n$lineToAdd"
}
}
Write-Verbose "Fetching remote submodules..."
git submodule update --init --recursive --remote
Assert-GitExitCode "Failed to update submodules"
Write-Host "Configured Successfully." -ForegroundColor Green
}
catch {
Write-Error "Failed to set Git submodule configurations: $_"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment