Created
March 31, 2016 09:23
-
-
Save rexxiang/4e9bbde0f04693c48412945571d8b9da to your computer and use it in GitHub Desktop.
migrate git repository from old server to new server
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( | |
| [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