It seems like you have to interact with github.com to initiate a pull request. Is this so?
-
3I don't see anything in their API for doing pull requests: http://develop.github.com/ – Adam Vandenberg Oct 27 '10 at 21:44
-
11There is now: http://developer.github.com/v3/pulls/#create-a-pull-request – seanf Dec 07 '11 at 02:53
-
1What operating system are you intending to do this on? – IgorGanapolsky Mar 25 '16 at 17:35
-
How to do this in Windows 8 or 10? – Mathivanan KP Dec 05 '16 at 11:08
-
I created a [bash script](https://github.com/mathiasvr/git-pr) for this, if anybody is interested. – mvr May 29 '17 at 18:30
-
2Related: Some good details on [how the pull requests are different](https://stackoverflow.com/q/6235379/465053) in Git (the software) and GitHub (the web service) – RBT Aug 12 '17 at 03:17
-
See the new `cli/cli` in [my answer below](https://stackoverflow.com/a/60197211/6309) – VonC Feb 12 '20 at 21:33
-
2In April 2020, that would be `gh pr create --fill`. See [my edited answer below](https://stackoverflow.com/a/60197211/6309 – VonC Apr 23 '20 at 20:53
11 Answers
UPDATE: The hub command is now an official github project and also supports creating pull requests
ORIGINAL:
Seems like a particularly useful thing to add to the hub command: http://github.com/defunkt/hub or the github gem: http://github.com/defunkt/github-gem
I suggest filing an issue with those projects asking for it. The github guys are pretty responsive.

- 70,845
- 23
- 144
- 140
-
8The github-gem included a facility to create pull requests for ages: `gh pull-request [user] [branch]`. – Holger Just Nov 03 '10 at 14:16
-
7Does it work without having Github forked the repo first, ie from a direct clone of the source repo? – Hari Honor Jan 07 '13 at 11:19
-
1@Holger Just and anyone else: That just creates the text of a pull request and does not by-pass the need for an on-Github fork. I have not found a way around that yet. I intend to try the 'pullr' utility posted below soon. See [here](https://github.com/defunkt/github-gem/issues/19) for the issue of people requesting full pull-request support from the github-gem. – mateor Apr 13 '13 at 19:34
-
3for fast command using `hub` : `hub pull-request -m "message pull request" -b master -h your_branch` – Gujarat Santana May 15 '18 at 02:06
-
1Don't know why it's not mention in the above docs, but for quick pull request merge, checkout your master branch do `hub merge https://github.com/repo/pull/1` – holmberd May 16 '19 at 17:22
-
1
Git now ships with a subcommand 'git request-pull' [-p] <start> <url> [<end>]
You can see the docs here
You may find this useful but it is not exactly the same as GitHub's feature.

- 2,190
- 4
- 29
- 50

- 875
- 7
- 8
-
10@NathanBasanese It generates human-readable text describing the pull request. The [git docs](http://git-scm.com/docs/git-request-pull) and [GitHub](https://git-scm.com/book/ch5-2.html#Forked-Public-Project) book say to e-mail this to the project maintainer, someone with write privileges on the shared repo (possibly github). The maintainer reviews the pull-request text you sent (rather than using github's online pull-request process). They can do a `git pull` of the url and branch indicated in your pull request to merge your changes into their local clone and push these changes up to github. – hobs Jul 11 '15 at 21:33
With the Hub command-line wrapper you can link it to git and then you can do
git pull-request
From the man page of hub:
git pull-request [-f] [TITLE|-i ISSUE|ISSUE-URL] [-b BASE] [-h HEAD]
Opens a pull request on GitHub for the project that the "origin" remote points to. The default head of the pull request is the current branch. Both base and head of the pull request can be explicitly given in one of the following formats: "branch", "owner:branch",
"owner/repo:branch". This command will abort operation if it detects that the current topic branch has local commits that are not yet pushed to its upstream branch on the remote. To skip this check, use -f.
If TITLE is omitted, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message.
If instead of normal TITLE an issue number is given with -i, the pull request will be attached to an existing GitHub issue. Alternatively, instead of title you can paste a full URL to an issue on GitHub.
-
2Didn't know about Hub, it is available via homebrew: `brew install hub` This seems like the correct answer for mac users. – wfbarksdale Dec 03 '12 at 22:58
-
1// , Is there anywhere online that I could point people to for more information about Hub? – Nathan Basanese Jul 03 '15 at 04:40
-
More information about the hub command is available here: https://hub.github.com/ – tresf Dec 10 '20 at 17:40
A man search like...
man git | grep pull | grep request
gives
git request-pull <start> <url> [<end>]
But, despite the name, it's not what you want. According to the docs:
Generate a request asking your upstream project to pull changes into their tree. The request, printed to the standard output, begins with the branch description, summarizes the changes and indicates from where they can be pulled.
@HolgerJust mentioned the github cli does what you want:
gh pull-request [user] [branch]
Others have mentioned the official hub
package by github:
sudo apt-get install hub
or
brew install hub
then
hub pull-request [-focp] [-b <BASE>] [-h <HEAD>]

- 18,473
- 10
- 83
- 106
-
3This generates a summary of pending changes, it has nothing to do with a pull request that is being issued via Github – Flov Jul 11 '12 at 07:04
-
1@Flov By "This", I assume you mean the `git request-pull` line. Yea, that makes sense, but I'm surprised git doesn't have a command to e-mail pull-requests like github does. After all, the `git config user.email` is available to it. Especially with a command named `pull-request`. – hobs Jul 11 '12 at 18:30
-
2For Ubuntu, looks like `github-cli` is no longer available after Precise...I've [opened a question](http://askubuntu.com/questions/422402/alternative-to-github-cli-after-quantal) to ask for an alternative. – IsaacS Feb 18 '14 at 02:22
-
-
@GamerAtmos Though it's not a pull request, it's close. On GitLab you can create a new private repository (project) using a normal `git` client with just a `git push -u origin master` with a new `origin` url. – hobs Feb 04 '21 at 22:52
In addition of github/hub
, which acts as a proxy to Git, you now (February 2020) have cli/cli
:
See "Supercharge your command line experience: GitHub CLI is now in beta"
Create a pull request
Create a branch, make several commits to fix the bug described in the issue, and use gh to create a pull request to share your contribution.
By using GitHub CLI to create pull requests, it also automatically creates a fork when you don’t already have one, and it pushes your branch and creates your pull request to get your change merged.
And in April 2020: "GitHub CLI now supports autofilling pull requests and custom configuration"
GitHub CLI 0.7 is out with several of the most highly requested enhancements from the feedback our beta users have provided.
Since the last minor release, 0.6, there are three main features:
- Configure
gh
to use your preferred editor withgh config set editor [editor]
.- Configure
gh
to default to SSH withgh config set git_protocol ssh
.
The default Git protocol is HTTPS.- Autofill the title and body of a pull request from your commits with
gh pr create --fill
.
So:
gh pr create --fill

- 1,262,500
- 529
- 4,410
- 5,250
-
-
@vap From https://cli.github.com/manual/gh_pr_create, yes, with the option `-r`, `--reviewer
` Request reviews from people or teams by their handle – VonC Apr 27 '22 at 14:10
I ended up making my own, I find that it works better the other solutions that were around.

- 10,746
- 7
- 43
- 50
-
6Tried doing pullr -n inside the cloned repository. Gave me an error opening .../clonedRepo/undefined/.pullr-token-cache on windows 7. You might want to have some more documentation - like an example usage? – B T May 28 '13 at 22:37
I'm using simple alias to create pull request,
alias pr='open -n -a "Google Chrome" --args "https://github.com/user/repo/compare/pre-master...nawarkhede:$(git_current_branch)\?expand\=1"'

- 8,234
- 12
- 59
- 81
-
2Which is not creating a PR, but opens a browser with PR creation page. – The Godfather Feb 25 '21 at 17:40
You can install github official CLI to create PR and do other sort of things.
To setup:
gh auth login
To create PR:
gh pr create
To merge:
gh pr merge

- 42,508
- 29
- 229
- 225
-
2Nobody can use these commands as shown, since you are not specifying the repos or branches operated on. A little more explanation of how to know what account is used in `auth login` and how to determine what repo the PR is created in (and for what account), etc. – not2qubit Jan 27 '22 at 10:20
-
2These are actually full commands. you can run these commands at the root path of the repo and `gh` will link these commands internally. For `gh auth login`, you'd be asked which acc. you'd like to login.. it's interactive. – GorvGoyl Jan 27 '22 at 11:44
I've created a tool recently that does exactly what you want:
https://github.com/jd/git-pull-request
It automates everything in a single command, forking the repo, pushing the PR etc. It also supports updating the PR if you need to edit/fix it!

- 500
- 4
- 7
I've used this tool before- although it seems like there needs to be an issue open first, it is super useful and really streamlines workflow if you use github issue tracking. git open-pull and then a pull request is submitted from whatever branch you are on or select. https://github.com/jehiah/git-open-pull
EDIT: Looks like you can create issues on the fly, so this tool is a good solution.

- 275
- 1
- 2
- 7
Yes. You can install the hub CLI util.
On MACOS: brew install hub
You need to have one time GitHub token for login.
User -> Dev settings -> Personal tokens -> Generate
(See: https://github.com/settings/tokens)
git checkout -b mybranch
hub pull-request -b master -h mybranch
#user: your_user_name
#password: your_git_token