web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / URGENT - Azure Devops ...
Power Automate
Unanswered

URGENT - Azure Devops - Create new branch from a repo sub branch

(0) ShareShare
ReportReport
Posted on by 802

Hi there, 

 

I have a manual process I am looking to automate.

 

This process consists of 

1) Going to a DevOps Project

2) Go to Repos > Files > a sub sub folder and Create a New Branch from here, based on main

3) Commit the file

4) Submit a pull request

 

This, when committed and the pull is done from this folder, starts a pipeline. 

 

I have a flow which currently

 

1) does a GET request on 

https://dev.azure.com/<org name>/<project name>/_apis/git/repositories/<repo id>/refs?filter=heads/main&api-version=5.1

which brings back the objectID for main on this repo.

 

2) Using the objectID from the GET, does a POST on

https://dev.azure.com/<org name>/<proj name>/_apis/git/repositories/<repo id>/pushes?api-version=5.1

with body of

{
 "refUpdates": [
 {
 "name": "refs/heads/<name of new branch>",
 "oldObjectId": "<objectID from GET command"
 }
 ],
 "commits": [
 {
 "comment": "<any name we give the file>",
 "changes": [
 {
 "changeType": "add",
 "item": {
 "path": "/<Filename>.json"
 },
 "newContent": {
"content": '<our JSON content>',
"contentType": "rawtext"}
 }
 ]
 }
 ]
}

 

3) Then does a pull request on this file using POST of

https://dev.azure.com/<org ID>/<proj name>/_apis/git/repositories/<repo ID>/pullrequests?api-version=5.1

with a body of

{
 "sourceRefName": "refs/heads/<our branch name we set in the POST>",
 "targetRefName": "refs/heads/main",
 "title": "<our title>",
 "description": "",
 "reviewers": [
 {
 "id": "<the ID for our approval team>"
 }
 ]
}

 

The above 'works' in as much as it does the steps I think I am telling it, and creates a branch for me, adds the file and it's content, and does the pull request. 

 

However, the instructions I have been given for DevOps itself, show that I need to go to a sub-path within the repo I am using, of 4 folders down in the files area of Repos, and create a new branch in there; then add the file to this branch, Commit it and do the pull request from here. This then, when the pull request is approved, triggers a pipeline.

 

I just don't know where I can specify this sub sub folder for the branch to be created, and then have the file created on this branch from a sub sub folder.... and then do the pull request on this branch into main. 

 

Any help appreciated.

 

Thanks

K.

 

 

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard