Carlo V. Dango
Carlo V. Dango

Reputation: 13912

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.

Upvotes: 3

Views: 7681

Answers (3)

VonC
VonC

Reputation: 1330102

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).

Upvotes: 10

Carlo V. Dango
Carlo V. Dango

Reputation: 13912

The api supports cloning remotly

https://developer.github.com/v3/repos/forks/#create-a-fork

Upvotes: 1

Andras
Andras

Reputation: 3055

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.

Upvotes: 2

Related Questions