Quantcast
Channel: Git push existing repo to a new and different remote repo server? - Stack Overflow
Viewing all articles
Browse latest Browse all 20

Answer by HuneycuttGIS for Git push existing repo to a new and different remote repo server?

$
0
0

This was my answer to moving from Microsoft Team Foundation Server to Azure DevOps. It is PowerShell script.

    #RUN SCRIPT FROM FOLDER YOU WANT A NEW GIT PROJECT CREATED##1. Ask for URL that needs to be cloned#2. Ask for branch to clone#3. Ask what to call the new GIT Project folder##4. RUNS THE CLONE##5. Ask if you want to get all branches from remote#    If YES:#    6. Gets all branches#    7. Ask if you want to remove the remote#        If YES:#        8. Removes remote#        9. Ask if you want to add a new remote#            IF YES:#            10. Ask for new remote URL#            11. PUSHES A MIRROR OF LOCAL REPO TO NEW REMOTE $RemoteRepo = Read-Host "URL TO REPO THAT NEEDS TO BE CLONE"$CloneBranch = Read-Host "BRANCH TO CLONE"$CloneFolderName = Read-Host "NEW FOLDER NAME"git clone -b $CloneBranch $RemoteRepo $NeedAllBranches = Read-Host "DO YOU NEED ALL BRANCHES? (YES OR NO)"if ($NeedAllBranches -eq 'YES')    {    cd ((Get-Location).Path +"\" + $CloneFolderName)    foreach ($branch in (git branch -r))    {git checkout -b $branch.Trim().Replace("origin/","")}     $RemoveRemote = Read-Host "DO YOU NEED TO REMOVE REMOTE?"    if ($RemoveRemote -eq 'YES')        {        git remote remove origin        $AddNewRemote = Read-Host "DO YOU WANT TO ADD A NEW REMOTE AND PUSH?"            if ($AddNewRemote -eq 'YES')            {                $NewRemoteURL = Read-Host "URL TO NEW REMOTE"                git remote add origin $NewRemoteURL                git push --mirror            }        }    else {        Write-Host "NOT REMOVING REMOTE"    }    }else {    Write-Host "NOT GETTING ALL VERSIONS"}

Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>