Reputation: 5805
I have a Azure DevOps/VSTS project with two Git repositories, repoMain
and repoMirror
. The repository repoMain
has a Master branch and a separate branch newBranch
. The repository repoMirror
is still empty.
How can I set up a build pipeline (with a Command Line task? Powershell task?) such that whenever something is checked in into newBranch
, the changes are pushed into the other repository repoMirror
? In other words, repoMirror
should always (and only) contain the current contents of newBranch
.
Upvotes: 1
Views: 968
Reputation: 525
Recently I also tried this for one of my projects. Let me give you all the steps that I followed.
Firstly create a newBranch branch in the repoMirror
Now create a CI build pipeline using a windows agent
Add a PowerShell script task with the following commands
git clone https://[email protected]/org/project/_git/repoMain
cd repoMain
git checkout newBranch
git remote add Reponame https://[email protected]/org/project/_git/repoMirror
git push Reponame newBranch -f
Finally create a trigger for repoMain --->newBranch So when ever there is any code update in repoMain --->newBranch the pipe will be executed
Upvotes: 1