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

gh pr create unnecessarily adds a remote and prompts for credentials if one has a fork #1286

Closed
foolip opened this issue Jun 29, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@foolip
Copy link

foolip commented Jun 29, 2020

Describe the bug

If one has a fork of a repository (but also have write access to the main repository), then gh pr create -f will add the personal fork as a fork remote, and try to push a branch there. That will ask for a username/password. But if fixed, it would also create a branch in the wrong repository.

gh version 0.10.1 (2020-06-24)

Steps to reproduce the behavior

  1. Clone a repository in an organization that you have write access to
  2. Ensure you have a personal fork of that repository
  3. Clone the original repository, and do not add your fork as a remote
  4. Check git remote -v at this point
  5. Make some change on a branch, and do gh pr create -f
  6. Check git remote -v at this point too

Expected vs actual behavior

At step 5, a remote named fork will be added and you may be prompted for credentials if you use SSH keys, which I do.

I do not want a remote to be added, I want to push a branch to the repository I have cloned, since I have write access to it.

Logs

The concrete example for me was https://github.com/whatwg/fullscreen which I have a fork of.

At step 4:

origin	git@github.com:whatwg/fullscreen.git (fetch)
origin	git@github.com:whatwg/fullscreen.git (push)

At step 5:

gh pr create -f gets stuck with a prompt:

Username for 'https://github.com':

At step 6:

fork	https://github.com/foolip/fullscreen.git (fetch)
fork	https://github.com/foolip/fullscreen.git (push)
origin	git@github.com:whatwg/fullscreen.git (fetch)
origin	git@github.com:whatwg/fullscreen.git (push)

Workaround

Delete your fork.

@mislav
Copy link
Contributor

mislav commented Jun 29, 2020

Hi, thank you for reporting! I see two problems here:

  1. You've expected the branch to be pushed to the origin repo, but it was pushed to a fork. This is currently by design gh pr create should allow defaulting to the private fork #350, but we will be re-evaluating this behavior Confirm base repo on first resolve #924. For now you can choose the push target by manually pushing the branch before invoking gh pr create.

  2. The fork remote was added using https, whereas it should have ideally followed the same protocol as the origin remote and used the SSH protocol. We are tracking this in gh repo fork adds remote using https protocol even if repository was cloned through ssh #1056, but for now you can configure your gh installation to always default to SSH URLs: gh config set git_protocol ssh

@mislav mislav closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants