Github API - create branch?

后端 未结 3 590
遥遥无期
遥遥无期 2020-12-13 04:14

Seems like it\'s missing from the \"Repos\" docs for v1, v2, and v3...how do I create a branch using the Github API?

3条回答
  •  感动是毒
    2020-12-13 04:21

    This is a common problem for all the students when we create API for creating a branch in GitHub

    {
      "message": "Not Found",
      "documentation_url": "https://developer.github.com/v3"
    }
    

    For solving this error during create repository in Github.....

    1. First create a personal token in

      Github=>setting=>developerOption=>generatePersonalToken...

                       or 
      

      during gitLogin bu Oauth when you pass client_id that time you pass scope=repo(Because it's allow all the Repository when you used token or anything)

    2. After that: hit the API(get)

      https://api.github.com/repos///git/refs/heads

    3. You got a response which is like

      Response => {
      [
      {
          "ref": "refs/heads/",
          "node_id": "jkdhoOIHOO65464edg66464GNLNLnlnnlnlna==",
          "url": " https://api.github.com/repos///git/refs/heads/",
          "object": {
              "sha": "guDSGss85s1KBih546465kkbNNKKbkSGyjes56",
              "type": "commit",
              "url": " https://api.github.com/repos///git/commits/guDSGss85s1KBih546465kkbNNKKbkSGyjes56"
          }
      }
      ]
      }
      
    4. Complete this process again hit API (Post)

      https://api.github.com/repos/Bhupi2508/Test/git/refs...
      

      And send data in JSON format like this:

      {
          "ref": "refs/heads/",
          "sha": "4661616ikgohlKIKHBK4634GRGSD66"
      }
      

      THEN YOU CREATE A BRANCH IN GITHUB By APIs

      And the process for Delete Branch hit only DELETE (first) APIs

提交回复
热议问题