Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Forked from Potherca/README.md
Created December 4, 2015 19:42

Revisions

  1. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ Just follow these steps:
    4. 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>",
    "ref": "refs/heads/<NEW-BRANCH-NAME>",
    "sha": "<HASH-TO-BRANCH-FROM>"
    }

  2. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -5,16 +5,16 @@ With the aid of [the Github API][1] and [hurl.it][2] this is a piece of cake!
    Just follow these steps:

    1. Open [http://hurl.it/][2]
    2. 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
    2. 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`
    3. Copy the revision hash
    4. Do a POST request from Hurl to https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs with the following as the POST body :
    4. 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)
    (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.

  3. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@ Just follow these steps:
    4. 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\>"
    "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)
    @@ -26,5 +26,10 @@ The situation I ran into, was that I found a web app that had a demo but the dem

    I've also used this to submit (simple) fixes to repos that require a pull-request from a branch that is not master.

    Do you have any other use cases or maybe any other service than Hurl that could be used?

    Let me know in the comments!


    [1]: http://developer.github.com/v3/
    [2]: http://hurl.it/
  4. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,14 @@ Just follow these steps:
    3. Copy the revision hash
    4. 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\>"
    }
    {
    "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)
    (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.
    You will need to use HTTP basic and fill in your Github credentials to access the Github API.

    5. Press the Send button and your branch will be created!

  5. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -8,17 +8,17 @@ Just follow these steps:
    2. 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
    3. Copy the revision hash
    4. 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>"
    "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!
    5. Press the Send button and your branch will be created!

    ---

  6. @Potherca Potherca revised this gist May 3, 2013. 1 changed file with 26 additions and 11 deletions.
    37 changes: 26 additions & 11 deletions Create-branch-with-Github-API.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,30 @@
    On http://hurl.it/ using HTTP basic AUTH and the inputs below you can
    create a branch on github without having access to a local git repo.
    Ever had the need to create a branch in a repo on Github without wanting (or being able) to access a local repo?

    (With "`<SHA-TO-BRANCH-FROM>`" being one of the latest commit in the repo,
    as shown by `https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads`).
    With the aid of [the Github API][1] and [hurl.it][2] this is a piece of cake!

    ===
    Just follow these steps:

    1. Open [http://hurl.it/][2]
    2. 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
    3. Copy the revision hash
    4. Do a POST request from Hurl to https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs with the following as the POST body :

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

    POST BODY :
    {
    "ref": "refs/heads/new-branch-name",
    "sha": "<SHA-TO-BRANCH-FROM>"
    }
    "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!

    ---

    The situation I ran into, was that I found a web app that had a demo but the demo wasn't hosted anywhere. So all I needed to do was clone the repo, create a branches called `gh-pages` (which automatically creates a site hosted by github) and I could watch the demo online without any local repo.

    I've also used this to submit (simple) fixes to repos that require a pull-request from a branch that is not master.

    [1]: http://developer.github.com/v3/
    [2]: http://hurl.it/
  7. @Potherca Potherca renamed this gist Jan 14, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. @Potherca Potherca revised this gist Oct 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,6 @@ create a branch on github without having access to a local git repo.

    POST BODY :
    {
    "ref": "refs/heads/test",
    "ref": "refs/heads/new-branch-name",
    "sha": "<SHA-TO-BRANCH-FROM>"
    }
  9. @Potherca Potherca revised this gist Oct 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ On http://hurl.it/ using HTTP basic AUTH and the inputs below you can
    create a branch on github without having access to a local git repo.

    (With "`<SHA-TO-BRANCH-FROM>`" being one of the latest commit in the repo,
    as shown by https://api.github.com/repos/`<AUTHOR>`/`<REPO>`/git/refs/heads).
    as shown by `https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads`).

    ===

  10. @Potherca Potherca revised this gist Oct 27, 2012. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    On http://hurl.it/ using HTTP basic AUTH and the inputs below you can
    create a branch on github without having access to a local git repo.

    (With "<SHA-TO-BRANCH-FROM>" being one of the latest commit in the repo,
    as shown by https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads).
    (With "`<SHA-TO-BRANCH-FROM>`" being one of the latest commit in the repo,
    as shown by https://api.github.com/repos/`<AUTHOR>`/`<REPO>`/git/refs/heads).

    ===

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

    POST BODY :
    {
    "ref": "refs/heads/test",
    "sha": "<SHA-TO-BRANCH-FROM>"
    }
    URL : https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs
    POST BODY :
    {
    "ref": "refs/heads/test",
    "sha": "<SHA-TO-BRANCH-FROM>"
    }
  11. @Potherca Potherca renamed this gist Oct 27, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt → gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    On http://hurl.it/ using HTTP basic AUTH and the inputs below you can
    create a branch on github without having access to a local git repo.

  12. @Potherca Potherca created this gist Oct 27, 2012.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@

    On http://hurl.it/ using HTTP basic AUTH and the inputs below you can
    create a branch on github without having access to a local git repo.

    (With "<SHA-TO-BRANCH-FROM>" being one of the latest commit in the repo,
    as shown by https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads).

    ===

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

    POST BODY :
    {
    "ref": "refs/heads/test",
    "sha": "<SHA-TO-BRANCH-FROM>"
    }