Hub: How can I pull request without fork original project?

Created on 29 Aug 2017  ·  4Comments  ·  Source: github/hub

Document doesn't say I have to fork first, but it looks like need.

A lot of tutorials , examples are like

http://sangsoonam.github.io/2017/02/01/create-pull-request-hub.html

❯ git co -b feature_branch
# Modify the code
❯ git add .
❯ git commit
❯ git push  (can not push)
# Create a pull request using hub
❯ git pull-request

If do as this would get

Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"

I think it is due to permission problem
https://github.com/github/hub/issues/1258
https://github.com/github/hub/issues/1518


I want to say, the normal scene I make pull request is when I see some project has bug and it is easy to fix.
If only change one file, I'd like to edit on web(it is convenient to pull-request just one file). When there are several files, it become complex. I have to fork the project, clone it , make edit, go to webpage make pull request, then I tend to delete the fork.

What I love to is :

  1. clone a project ( I don't have permission )
  2. make change
  3. hub pull-request

Can I use hub to do such thing? if not, would you add this feature?

Most helpful comment

@masaeedu You can of course create a PR for your own repo. You don't need to create a fork. You just need to create a new branch:

# in your project's directory:
git checkout -b my-feature
git commit -m "my new feature"
git push -u origin HEAD

hub pull-request # creates a PR with `my-feature` as head branch

All 4 comments

You can't open a pull request without forking the original project.

The way it works on the GitHub web interface is that, when you edit someone else's file in a browser, GitHub automatically creates your fork in the background.

With hub, you have to use hub fork before using hub pull-request. This is outlined in the docs:

# Example workflow for contributing to a project:
$ git clone github/hub
$ cd hub
# create a topic branch
$ git checkout -b feature
# ( making changes ... )
$ git commit -m "done with feature"

# It's time to fork the repo!
$ git fork
# (forking repo on GitHub...)
# git remote add YOUR_USER git://github.com/YOUR_USER/hub.git

# push the changes to your new remote
$ git push YOUR_USER feature
# open a pull request for the topic branch you've just pushed
$ git pull-request
# (opens a text editor for your pull request message)

In the future, hub might auto-create a fork for you, but for now, you have to invoke one extra command yourself.

So how is this supposed to work when I want to open a PR for my own repo? [myusername]/[myrepo] already exists; it's the original repo, so what do you fork to?

@masaeedu You can of course create a PR for your own repo. You don't need to create a fork. You just need to create a new branch:

# in your project's directory:
git checkout -b my-feature
git commit -m "my new feature"
git push -u origin HEAD

hub pull-request # creates a PR with `my-feature` as head branch

@mislav i think your code snipped should updated with:

 # Example workflow for contributing to a project:
 $ git clone github/hub
 $ cd hub
 # create a topic branch
 $ git checkout -b feature
 # ( making changes ... )
 $ git commit -m "done with feature"

 # It's time to fork the repo!
-$ git fork
+$ hub fork
 # (forking repo on GitHub...)
 # git remote add YOUR_USER git://github.com/YOUR_USER/hub.git

 # push the changes to your new remote
 $ git push YOUR_USER feature
 # open a pull request for the topic branch you've just pushed
-$ git pull-request
+$ hub pull-request
 # (opens a text editor for your pull request message)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cbeams picture cbeams  ·  4Comments

JacobJae picture JacobJae  ·  4Comments

stsewd picture stsewd  ·  4Comments

xxmyjk picture xxmyjk  ·  4Comments

jfritzbarnes picture jfritzbarnes  ·  3Comments