Skip to content

pr create assumes local branch name #1869

@opdavies

Description

@opdavies

Describe the bug

I have a workflow where I work on a branch (e.g. document-feature-flags-GH-401) locally and add a prefix when pushing it to GitHub (e.g. opdavies-document-feature-flags-GH-401). This means that in most cases, my local branch name does not match the remote branch name, but the local branch is tracking the remote branch.

For example, if I run git branch -vv:

document-feature-flags-GH-401          24849ad69 [origin/opdavies-document-feature-flags-GH-401] Document the use of feature flags

In this situation, the CLI currently assumes that the remote branch name is document-feature-flags-GH-401, and not the remote tracking branch name. This could be solved by making this the default behaviour and checking for the remote branch's name when creating the PR, or by allowing the option to specify the branch name using an argument similar to --base for the base branch.

Steps to reproduce the behavior

  1. Create a branch (e.g. test)

  2. Push it to GitHub using a different name (git push -u test:test2)

  3. Run gh pr create and see that it uses the local branch name rather than the remote one

     Creating pull request for test into develop
    

Expected vs actual behavior

Use the remote tracking branch name rather than the local one.

Logs

~/Code/clients/xxx test [24849ad69] * $ git push origin -u test:test2
Total 0 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'test2' on GitHub by visiting:
remote:      https://github.com/odwd/xxx/pull/new/test2
remote: 
To github.com:odwd/xxx.git
 * [new branch]          test -> test2
Branch 'test' set up to track remote branch 'test2' from 'origin' by rebasing.
                                                                                                                                                                                           
~/Code/clients/xxx test [24849ad69] * $ gh pr create                 
Warning: 1 uncommitted change

Creating pull request for test into develop in odwd/xxx

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions