probotoctokit-js

How to create a branch using probot (octokit)?


I want to create a branch using Probot. Seeing that it uses octokit/rest.js, I went over the octokit docs but couldn't find a method to do so. So how do I create a branch?

Also note that I mean to create a branch so I can pull request later.

Edit: This seems to be the way to do it, but it's confusing.


Solution

  • Yes @Siddharth,

    The way to do it is as you pointed. I found this good explanation in StackOverflow: Github API - create branch?

    Also, using Octokit SDK, you can easily achieve it like this:

    octokit.rest.git.createRef({
      owner,
      repo,
      ref,
      sha,
    });
    

    docs here: https://octokit.github.io/rest.js/v18#git-create-ref