Created
June 27, 2025 10:55
-
-
Save rfennell/a89c92fa91aa4eb2976cb97391e93375 to your computer and use it in GitHub Desktop.
Exports branches from SVN and creates a Git repo (no history)
This file contains hidden or 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
param | |
( | |
$localrepopath = "c:\svn\localrepo", | |
$trunkurl = "svn://svnlive.mydomain/application/trunk", | |
[string[]]$branches = @( | |
"svn://svnlive.mydomain/application/releases/1.0.0", | |
"svn://svnlive.mydomain/application/releases/2.0.0" | |
) | |
) | |
function exportbranch ( | |
$url, | |
$branchname, | |
$localrepopath | |
) | |
{ | |
cd $localrepopath | |
Write-Host "Exporting '$url' to branch '$branchname'" -ForegroundColor Green | |
& git checkout -b $branchname | |
& svn export $url $localrepopath --force | |
Write-Host "Commiting branch '$branchname'" -ForegroundColor Green | |
& git add . | |
& git commit -m "Initial Commit to $branchname" | |
} | |
Write-Host "Create a git repo in '$localrepopath'" -ForegroundColor Green | |
$null = new-item -Path $localrepopath -ItemType directory | |
Copy-Item $PSScriptRoot\.gitignore $localrepopath -Force | |
cd $localrepopath | |
& git init -b main | |
exportbranch -url $trunkurl -branchname 'main' -localrepopath $localrepopath | |
$branches | foreach-object { | |
$branchname = $_.Split("/")[-1] | |
exportbranch -url $_ -branchname $branchname -localrepopath $localrepopath | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment