Automatically open a pull request on github by command line

13,463

Solution 1

Finally success

The first problem is that I was using the key password and not my github password.

With this structure:

Private Organization:

name: Org
repository: main
branch: master

Private Fork:

name: OrgFork (A organization of mine with forks from **Org**) 
repository: main
branch: testing

And the other problem is I was needing accept the corrects parameters, the final command looks like this one:

hub pull-request "Testing pull-request" -b Org:master -h OrgFork:testing

Thx for help @cjc343, @StevenPenny, @desert69 =)

Solution 2

You should check out hub, a command line tool to interact with GitHub.

Its README talks about making pull requests.

Share:
13,463

Related videos on Youtube

GarouDan
Author by

GarouDan

Senior Full-Stack Software Engineer specialized in backend. 8+ years of commercial experience. Very interested in AI and ML. Bachelor’s degree in Information Systems, post-graduation's degree in Java Technology and Development for Mobile Devices. Knowledge in several programming languages (mainly Kotlin and Java), technologies and other topics related to IT and mathematics. Self-teaching, ease in learning new technologies or improving and optimizing processes, ability in computer and exact sciences, teamwork. Bachelor's thesis defended in the field of AI and Fuzzy Systems. My CV is available at this link.

Updated on June 04, 2022

Comments

  • GarouDan
    GarouDan almost 2 years

    I'm using git to versioning a collaborate project.

    And I have two remotes. fork is a fork of an project, and origin is the original project.

    So, could I when I send a push (git push fork master) automatically create a pull request available in origin to merge it?

    I can't commit directly to origin (I know this is possible). I need push first to fork and if the admin aproves it, accept on origin. I would like automate this process, avoiding me to manually go to github and open a fork.

    How could I do this?

    Edit:

    Private Organization:

    name: Org
    repository: main
    branch: master
    

    Private Fork:

    name: OrgFork (A organization of mine with forks from **Org**) 
    repository: main
    branch: testing
    

    I tried the following approach, but didn't worked yet:

    curl -X POST -u <Username> -k -d '{"title": "<Title>","head": "Org:main","base": "testing"}' https://api.github.com/repos/Org/main/pulls
    

    what is wrong? How can I fix this?

    Edit 2

    Another attempt:

    hub pull-request "Testing" -b OrgFork:main:testing -h OrgFork:main:master
    
  • GarouDan
    GarouDan about 11 years
    Unfortunally hub isnt working correct for me. I have the following error: Error creating pull request: Unauthorized (HTTP 401). I tried see why this error and the best thing I had encountered is use git config github.token, but this didn't worked too. I working with a private repo.