Forum Discussion
LanceLyons
Jan 08, 2024Copper Contributor
Auto create 3 branches when a repository is created in Azure DevOps Git
Hi, Is there a way to trigger the creation of branches when a new repository is created in Azure Git? I know we can automate the creation of an azure git repository and then create the branche...
LanceLyons
Feb 02, 2024Copper Contributor
Thanks. I looked at that approach and did actually implement it but it seemed like branches I had in my template repo, did not actually get created in the new repo unless I first created them in the template repo during the process. so my process in a pipeline looks like this now but it works. not sure I needed the template repo for this however
az repos create --name a.test --organization https://dev.azure.com/org/ --project Onlife
git clone -q https://$(PAT)@dev.azure.com/org/project/_git/repo.template
cd repo.template
git config --global user.email "email address removed for privacy reasons"
git config --global user.name "lance_lyons"
-------------- added to have breanches show up in new repo -----------------
git checkout -b release
git checkout -b development
git checkout -b hotfix
git add -A
--------------------------------------------------------
git commit -am "Copied from project repo.template"
git remote rename origin repo.template
git remote add origin https://$(PAT)@dev.azure.com/org/project/_git/a.test
git push -u origin main
git push -u origin --all