Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 185809
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 10, 20222022-06-10T07:26:59+00:00 2022-06-10T07:26:59+00:00

git – Create new branch from a repo sub “folder”

  • 0

[ad_1]

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.

  1. 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"}
     }
   ]
 }
]
}
  1. 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.

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 325 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 295 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 292 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.