-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Comments
Yes, the default branch is usually master. If you want to open a pull request against a different branch, use the
|
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. |
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. |
FWIW, we would appreciate this feature as well. It would be really great if hub could determine github's default branch itself. |
A section in .git/config will be good enough. And everybody who use |
Just got bit by this by accidentally merging a pull request to |
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 |
Yeah, I think reading the default branch set on GitHub should be enough. |
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. |
I might take a stab at this implementation this weekend. I want this very much too. |
Closing in favor of #326 |
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
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
For future searchers (as this is top of Google), to set the correct branch:
|
Or you can run |
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"} |
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
The text was updated successfully, but these errors were encountered: