1

I have two repository, first on Azure DevOps, second on GitHub. I'd like to update GitHub repository to have the same code on both repositories. How can I do it without manually copying source code?

Hong Ooi
  • 54,701
  • 13
  • 127
  • 173
riko1520
  • 31
  • 1
  • 2
  • Hi , is there any update for this issue? I answered detailed steps in my [another issue](https://stackoverflow.com/a/61335270/10910450) about how to configure the pipeline to sync repos, hope it also makes some help for you. And feel free to let me know if that still blocks you, a reminder of [this rule](https://stackoverflow.com/help/someone-answers) :) – LoLance Apr 21 '20 at 03:09

2 Answers2

5

You can include a Pipeline step that runs git, to copy the repo over. Something like this:

steps:
- bash: |
    git push --prune https://$(GITHUB_PAT)@github.com/$REPO_NAME \
        +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*
  displayName: 'Copy to Github'
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')

(Copied from https://github.com/Azure/AzureStor/blob/master/azure-pipelines.yml, slightly modified)

Hong Ooi
  • 54,701
  • 13
  • 127
  • 173
4

How can I do it without manually copying source code?

As I know Azure Devops Repos itself doesn't have such feature to monitor git repos and automatically keep these two repos in sync.

However I think there's some workarounds for your requirements. You can check this blog for the details about how to use git commands in pipeline to do what you expect above. Also, the free Git Tools for Azure Devops extension designed for synchronise one Git Repository with another may help for your scenario.

In addition: If you do like this sync feature, feel free to submit a feature request here in Azure Devops's User Voice forum. The product team would consider about your idea and gives reply if there's any update.

LoLance
  • 22,153
  • 1
  • 27
  • 59