bhuvi
bhuvi

Reputation: 21

how do i automatically pull code from master to fork in azure repos using azure devOps pipeline

I was trying to pull the code from master to fork repository automatically through the azure pipeline. If any one know about this?

Upvotes: 1

Views: 2240

Answers (1)

Edward Han-MSFT
Edward Han-MSFT

Reputation: 3205

If you fork azure repo and want to automatically sync the Fork repo using VSTS Git, please follow below steps.

  1. Supposed the url of original repo is https://dev.azure.com/{organization}/{project}/_git/test, and the url of forked repo is https://dev.azure.com/{organization}/{project}/_git/test_fork.
  2. If you click "Clone" button in test repository, you will see below panel. enter image description here
  3. Clicking "Generate Git Credentials" button will show the following panel. enter image description here So we can use command git remote add upstream https://username:[email protected]/{organization}/{project}/_git/test to specify it as the upstream of test_fork repo in script.
  4. Now creating a build pipeline using Microsoft-hosted Windows agents, setting the test_fork as the source. enter image description here
  5. Adding the Command Line task with below script.
git remote add upstream https://username:[email protected]/{organization}/{project}/_git/test
git fetch upstream
git rebase upstream/master
git push -f origin HEAD:master
  1. Queuing a new build and it will succeed to sync the test_fork repo using VSTS Git.
  2. You can also configure schedules for this pipeline. Now everything is done.
  3. If you use GitHub repo, please refer to this thread for guidance.

Upvotes: 2

Related Questions