Skip to content

pr create assumes local branch name #1869

Closed

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

Activity

  1. added
    bug
    on Sep 20, 2020
  2. mislav commented on Sep 21, 2020

    @mislav
    Contributor

    Thank you for reporting!

    For now, I think the upstream configuration will be detected if the branch is fully pushed before calling pr create. So you might need to do git push && gh pr create as a workaround.

  3. opdavies commented on Sep 21, 2020

    @opdavies
    Author

    Hi @mislav. This doesn't seem to be the case for me.

    I've just tried it with gh v1.0.0, and it still assumes that the local branch name matches the remote one.

    If I check git log, I can see both refs listed:

    commit 17a5a9592a0fcb27ad54eb42d8c35544728b93a4 (HEAD -> export-google-tag-config, origin/opdavies-export-google-tag-config)
    
  4. self-assigned this
    on Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions