Open a GitHub Pull Request with Hub
The basic workflow is to create a branch, add your changes, and then push it to GitHub (I’m pushing to my origin, I’m not sure what happens if you’re pushing to somewhere else but if you know then please add a comment). Then you have a few options:
- Create a pull request against origin/master (this is the default):
hub pull-request
- Create a pull request against another repo, you’d probably use this for open source or any other situation where you are pushing to a fork but requesting a pull against an upstream repo; use the
-b
switch and the formatowner:branch
:hub pull-request -b joindin:master
- Create a pull request against a branch called something other than “master”:
hub pull-request -b develop
- Create a pull request against something else entirely! The argument is in the format
owner/repo:branch
for that
It’s fairly common also to alias your “hub” command to “git”, which gives you all your existing git functionality with a few special GitHub-aware features like the pull request command you’ve seen above. I personally don’t have it set up this way, but if you do then you can simply s/hub/git/
in the above examples.
If the changes you want to pull request aren’t in “the branch named what I’m currently on, in the origin repo” then you can use the same format of arguments with the -h
switch also. Whether you prefer to work from commandline, or you’re looking to wrap up some of your process in a scriptable way, hub could be pretty handy.
Good article. Is there a way to set an assignee when you do this?