1

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 NameOfAzdoOrganization@dev.azure.com/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://NameOfAzdoOrganization@dev.azure.com/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?

CodeMed
  • 9,527
  • 70
  • 212
  • 364
  • @KevinLu-MSFT This is part of a multi-faceted problem. We are addressing other aspects of the problem and will revisit this when the other items are resolved. – CodeMed Jun 18 '20 at 04:35
  • If you have any update, feel free to let me know. Thanks. – Kevin Lu-MSFT Jun 18 '20 at 08:06

2 Answers2

3

The computer on location A has to clone the repo from location b

git clone github.com/someuser/source-repo.git

then add the repo in location C as remote

git remote add locationC https://NameOfAzdoOrganization@dev.azure.com/NameOfAzdoOrganization/NameOfAzdoProject/_git/NameOfAzdoProject

then push to location C

git push -u locationC

You can add --all to that last command if you wish to push all branches instead of jsut the default branch.

Unless the repo in location B has a mirroring functionality (like, gitlab let's you mirror any pushes done to a repo to another remote repo), I believe you have to jump through this hoop.

Sandy
  • 127
  • 5
  • I was imagining something like `az azdo pull fromLocationB toLocationB` . That would reduce location A to simply calling a command or two instead of transporting an entire repo. – CodeMed Jun 15 '20 at 20:29
  • Sorry, unfortunately I haven't used az for working with git yet. I do expect azure devops to have a monitoring setting that automatically pulls any changes made on another remote. – Sandy Jun 15 '20 at 20:34
1

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.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • 1
    Getting your suggestion to work required several additional steps that you did not list in your answer. For example, we first had to type `export AZURE_DEVOPS_EXT_PAT=xxxxxxxxxx` with a valid `personal access token` that had sufficient privileges. We also had to type `az extension add --name azure-devops` to install the `azure-devops` extension to the `az` cli tool. Then we were finally able to run `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}` . – CodeMed Jun 25 '20 at 20:05