Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

git - Automatically open a pull request on github by command line

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Its README talks about making pull requests.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...