Skip to content

Instantly share code, notes, and snippets.

@rexxiang
Created March 31, 2016 09:23
Show Gist options
  • Select an option

  • Save rexxiang/4e9bbde0f04693c48412945571d8b9da to your computer and use it in GitHub Desktop.

Select an option

Save rexxiang/4e9bbde0f04693c48412945571d8b9da to your computer and use it in GitHub Desktop.
migrate git repository from old server to new server
Param(
[Parameter(Mandatory=$true)]
[string]$OriginUrl,
[Parameter(Mandatory=$true)]
[string]$TargetUrl
)
$dir = ([System.Uri]$OriginUrl).Segments | select -Last 1
if(Test-Path $dir) {
Remove-Item -Path $dir -WhatIf $true
}
git clone --mirror $OriginUrl $dir
cd $dir
git push --mirror $TargetUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment