Search code examples
gitgithubazure-devopsazure-cliazure-git-deployment

git push between two remote repositories


What specific syntax needs to be used in order for a computer at an arbitrary location on the internet (location A) to trigger a git push from a public GitHub repository github.com/someuser/source-repo (location B) to a private Azure Git Repo [email protected]/NameOfAzdoOrganization/NameOfAzdoProject/_git/NameOfAzdoProject (location C)?

The empty remote Azure Git Repo (location C) gives the following code to push from a local repo at location A to populate remote location C:

git remote add origin https://[email protected]/NameOfAzdoOrganization/NameOfAzdoProject/_git/NameOfAzdoProject
git push -u origin --all

But what command needs to be run on location A in order to push from location B to location C?


Solution

  • I was imagining something like az azdo pull fromLocationB toLocationB.

    As far as I know, the sandy method is effective.

    From you requirement, Location C in Azure Repo is empty. And you want to move the repo from github to Azure Repo.

    You may try to use the az repos import command in Location A.

    az login 
    
    az repos import create --git-source-url https://github.com/xxx/xxx.git --repository {Location C Repo name} --organization https://dev.azure.com/{Org name} --project {Project name}
    

    Note: the repo in Location C needs to be empty. It doesn't support importing repo that already has content.

    This method is to import the repo in Github directly to Azure Repo. It has limitations.

    Hope this can give you a little help.