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 a 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

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:45:19+00:00 2026-05-30T14:45:19+00:00

Seems like it’s missing from the Repos docs for v1, v2, and v3…how do

  • 0

Seems like it’s missing from the “Repos” docs for v1, v2, and v3…how do I create a branch using the Github API?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:45:21+00:00Added an answer on May 30, 2026 at 2:45 pm

    The V3 API mentions branches in its reference page

    The ref in the URL must be formatted as heads/branch, not just branch.
    For example, the call to get the data for a branch named sc/featureA would be:

    GET /repos/:user/:repo/git/refs/heads/sc/featureA
    

    Create a Reference

    POST /repos/:user/:repo/git/refs
    

    Parameters

    ref
    

    String of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.

    sha
    

    String of the SHA1 value to set this reference to

    So it should be possible to create a new branch, by naming a new ‘/heads‘ in the ref parameter.


    Potherca points out to a working test, using the service of www.hurl.it (which makes HTTP requests)

    • Find the revision you want to branch from.
      Either on Github itself or by doing a GET request from Hurl:

      https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads

    • Copy the revision hash

    • Do a POST request from Hurl to https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs with the following as the POST body :

        {
            "ref": "refs/heads/<NEW-BRANCH-NAME>",
            "sha": "<HASH-TO-BRANCH-FROM>"
        }
      

      (obviously replacing the <NEW-BRANCH-NAME> with the name your want the new branch to have and the <HASH-TO-BRANCH-FROM> with, you know, the hash of the revision you want to branch from)

      You will need to use HTTP basic and fill in your Github credentials to access the Github API.

    • Press the Send button and your branch will be created!


    In 2022, you can also use gh api

    gh api \
      --method POST \
      -H "Accept: application/vnd.github.v3+json" \
      /repos/OWNER/REPO/git/refs \
      -f ref='refs/heads/featureA'
     -f sha='aa218f56b14c9653891f9e74264a383fa43fefbd'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like this might be easy, but from reading other SO answers there are
Seems like more companies are using Ruby on Rails nowadays. What are some other
Seems like everyone have issue accessing local machine or internet etc from emulator. All
It seems like the Azure Compute Emulator does not inherit the permissions from the
This seems like it should be simple but I can't work it out from
Seems like this should be easy but I must just be missing something... I
Seems like a simple enough question but I can't seem to find the answer.
Seems like a simple problem: I have an SVN repo inside our firewall. I
Seems like the subtraction is triggering some kind of issue and the resulting value
Seems like as really simple thing to do, but I just can't track it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.