Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using the github API, Create git pull request without checking out the code

How can I create a github pull request for a project that I haven't checked out using the github api. I want to automate simple changes to repositories, that I need not check out first. I simply want to pull a file from raw.githubusercontent.com modify it and create said pull request.

EDIT The github web user interface allows to edit foreign files by cloning and creating a pull request in the back ground.

like image 860
Carlo V. Dango Avatar asked Aug 29 '26 23:08

Carlo V. Dango


2 Answers

2015:

I haven't checked out using the github api.

You should at least have forked the repo first (see GitHub API create a fork)

Then "Create a Pull Request" supposes you have pushed a commit to a dedicated branch (API "Create a commit" first, which supposes to create a tree first, based on creating a blob).

For all those operations, I would suggest using a wrapper to the GitHub API like go-github, which might make the all series of operation easier to chain.


2023:

The GitHub CLI allows for:

  • gh repo fork to create a fork of a repository (without cloning it locally).
  • gh pr create --web to create a pull request on GitHub, from the web interface (so no local checkout required, assuming you have a branch ready to be merged).
like image 79
VonC Avatar answered Aug 31 '26 14:08

VonC


You had to have checked it out, but you can use scripted command line to do it.

A pull request asks that a particular git commit be merged into the main repository, not that a set of edits be made to files. You can only merge in commits if you have a writable copy of the github repo, which you can only get by cloning or forking the project.

like image 38
Andras Avatar answered Aug 31 '26 13:08

Andras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!