`hub pull-request` picks wrong project as default head #244

kballenegger opened this Issue Oct 10, 2012 · 11 comments


None yet
6 participants

Say you have a remote such as this:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com:ChartBoost/server.git

In this case, ChartBoost is a GitHub organization and this is a private repository.

When creating a pull request for a branch test with hub pull-request with no head or base arguments, you'd expect base to be ChartBoost:master, and head ChartBoost:test.

Instead, head is set to kballenegger:test by default (my GitHub username), which doesn't exist.

PS: I'm also confused, while we're on the subject, why the head/base strings are user:branch, without mentioning the actual repository (eg. user/repo:branch)?


mislav commented Nov 5, 2012

If you set upstream configuration for your branch (git push -u mybranch) then the default head should be ChartBoost:mybranch. With no upstream config, hub can't know to which remote you've pushed your code.

However I agree it can be a little smarter. Especially if you have a single remote set up (is that right?)

pj4533 commented Jan 16, 2013

yeah, i ran into this too. I usually push branches like this:

git push origin featurebranch

So I should do:

git push -u featurebranch

Is that right?


mislav commented Jan 21, 2013

@pj4533 Yep, with the -u flag you set upstream configuration and then hub knows exactly what is pushed where.

claco commented Feb 22, 2013

Is it possible to add a config for this default? i.e. remote = upstream

My normal workflow is to have a remote called upstream that points to the project parent I forked from.
With pull-request by itself picking origin:master, I'm just pull requesting to myself which is never what I want.
Instead, I'm always doing pull requests to the fork parent repo master, not my master.

Typing in -h parent/project:branch get's a little old after a while when it's all you do. Just a thought.

chaselee commented Apr 2, 2013

Just starting using Hub. Noticed this behavior as well. We just use one remote, not per-user forks, so it would be awesome to default the head to the origin as a configuration. Looked around the code a bit to see if I could create a pull, but I'm not a Ruby expert 😞


mislav commented Apr 2, 2013

@chaselee As per above comments, you should push your branches like git push -u origin mybranch. Then from "mybranch" you can simply do pull-request and it will figure it out.

I think I might be able to fix this and do the right thing even if you didn't push -u, but I don't know when I'll have time for that. Contributions welcome!

chaselee commented Apr 2, 2013

Thanks @mislav, that's what I've been doing as a temporary fix. I might try to sharpen my Ruby skills on implementing this. If you have a direction you can point me in, I'm happy to contribute. Getting off the ground is a bit tough though. Thanks again!


mislav commented Jul 17, 2013

Duplicate of #158. I'm working on fixing this, BTW. Follow the other ticket for updates!

@mislav mislav closed this Jul 17, 2013

Hum, isn't it something related to config push.default = current? I have it set and hub keeps being mislead.


mislav commented Jul 31, 2013

@fuadsaud I'm working on hub better supporting various upstream configurations, such as push.default awareness.

@mislav nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment