Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hub pull-request should allow a different default branch to be set #154

Closed
wagenet opened this issue Mar 26, 2012 · 14 comments
Closed

hub pull-request should allow a different default branch to be set #154

wagenet opened this issue Mar 26, 2012 · 14 comments
Labels

Comments

@wagenet
Copy link

wagenet commented Mar 26, 2012

Right now it's hardcoded to default to "master".

https://github.com/defunkt/hub/blob/master/lib/hub/commands.rb#L118
https://github.com/defunkt/hub/blob/master/lib/hub/context.rb#L149

@mislav
Copy link
Owner

mislav commented Mar 26, 2012

Yes, the default branch is usually master.

If you want to open a pull request against a different branch, use the -b option:

git pull-request -b [<owner>/]<branch>

@wagenet
Copy link
Author

wagenet commented Mar 26, 2012

Yeah, I discovered this. I was just thinking it would be nice to set a config default somewhere since Github itself allows you to set a default branch.

@mislav
Copy link
Owner

mislav commented Mar 26, 2012

Maybe. Not sure if it's worth it. I have come across one or two repos that have their main branch other than "master" (in fact, they might not have a "master" at all), but my experience alone hardly justifies adding and maintaining another hub option.

I'll think about this.

@debonet
Copy link

debonet commented May 7, 2012

FWIW, we would appreciate this feature as well.

It would be really great if hub could determine github's default branch itself.

@nilcolor
Copy link

A section in .git/config will be good enough. And everybody who use git flow is with develop branch as default target for PR's.

@danharper
Copy link

Just got bit by this by accidentally merging a pull request to master instead of our default branch develop, so this feature would be appreciated. (We're following a model similar to git flow)

@mislav
Copy link
Owner

mislav commented Dec 18, 2012

Sure, I'm for this. The default branch for a project would be read from GitHub API, right?

I'm not familiar with git flow and the local conventions it has, but I would avoid detect its setup locally and simply read it from GH API. This has a side-effect of adding 1 additional HTTP request to pull-request command and slowing it down a little.

@danharper
Copy link

Yeah, I think reading the default branch set on GitHub should be enough.

@mislav
Copy link
Owner

mislav commented Dec 18, 2012

Since I don't have time to implement this right now, you're welcome to take a stab at doing it. Test are a must in the end but even a proof of concept would be good for starters.

@farmdawgnation
Copy link

I might take a stab at this implementation this weekend. I want this very much too.

@mislav
Copy link
Owner

mislav commented May 12, 2013

Closing in favor of #326

@mislav mislav closed this as completed May 12, 2013
mislav added a commit that referenced this issue Jul 16, 2013
This is usually "master" but for e.g. git-flow projects it's "develop".
GitHub has an API field for the default branch but I avoided having to
hit the API and instead read from the "head" of the origin remote.

  git rev-parse --symbolic-full-name origin
  #=> refs/remotes/origin/develop

The "head" of the remote seems to be set at clone time by default, and
can be manually set with:

  git remote set-head origin develop

The pull-request command now detects this and sets the default branch as
the pull request base instead of always assuming "master" at origin.

Fixes #154, closes #326
mislav added a commit that referenced this issue Dec 18, 2013
This is usually "master" but for e.g. git-flow projects it's "develop".
GitHub has an API field for the default branch but I avoided having to
hit the API and instead read from the "head" of the origin remote.

  git rev-parse --symbolic-full-name origin
  #=> refs/remotes/origin/develop

The "head" of the remote seems to be set at clone time by default, and
can be manually set with:

  git remote set-head origin develop

The pull-request command now detects this and sets the default branch as
the pull request base instead of always assuming "master" at origin.

Fixes #154, closes #326
@danielcompton
Copy link
Contributor

For future searchers (as this is top of Google), to set the correct branch:

git remote set-head origin <new-branch>

@christopher-francisco
Copy link

Or you can run git remote set-head origin -a to have it automatically determine what's the correct base branch.

@csaska
Copy link

csaska commented Feb 27, 2020

This doesn't seem to work when I create the pull-request from a worktree; however, if I switch back to the original clone, the command works perfectly.

From the worktree, I see the following:

{"base":"master","head":"pHWChip:feature/colt_testing","maintainer_can_modify":true,"title":"Testing"}

From the original clone, I see the following:

{"base":"core_master","head":"pHWChip:feature/colt-testing-2","maintainer_can_modify":true,"title":"Testing"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants