Reputation: 44305
In git/github I want to propose a change to a single file.
To do so, I
Now how can I programatically (via API) create a new pull request to merge the changes I have put in the forked repo to the original repo? How to do that?
The documentation only seems to handle the case when it is the same repository.
Upvotes: 0
Views: 1694
Reputation: 13923
The documentation can be confusing. The following request will create a new pull request on FORKOWNER/THEREPO
to merge FORKER:newbranch
into FORKOWNER:main
:
curl -X POST -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/FORKOWNER/THEREPO/pulls \
-d '{"title":"XYZ", "body":"ABC", "head":"FORKER:newbranch", "base":"main"}'
This can also be done with the gh api
command of the GitHub CLI:
gh api --method POST -H "Accept: application/vnd.github.v3+json" \
repos/FORKOWNER/THEREPO/pulls \
-f title='XYZ' -f body='ABC' -f head='FORKER:newbranch' -f base='main'
Or directly with the gh pr create
command of the GitHub CLI:
gh pr create --repo FORKOWNER/THEREPO \
--title "XYZ" --body "ABC" --head FORKER:newbranch --base main
Upvotes: 3