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

Breaking behavior change: pushing topic branch to wrong remote #1762

Closed
heaths opened this issue Sep 17, 2020 · 7 comments · Fixed by #1926
Closed

Breaking behavior change: pushing topic branch to wrong remote #1762

heaths opened this issue Sep 17, 2020 · 7 comments · Fixed by #1926
Assignees
Labels
bug Something isn't working needs-investigation CLI team needs to investigate

Comments

@heaths
Copy link
Contributor

heaths commented Sep 17, 2020

Describe the bug

I've been testing gh for quite a while now, and even in v0.12.0 when I ran gh pr create -w the branch was pushed to my origin remote automatically. I was never asked (my clone uses origin for my fork and upstream for the main). Now in v1.0, I was asked:

Which should be the base repository (used for e.g. querying issues) for this directory?

It listed both endpoints, and since the message above reads, "e.g. for querying issues", I chose upstream.

It then printed and acted on accordingly,

Opening github.com/Azure/azure-sdk-for-net/compare/master...issue15108 in your browser.

That's not where my topic branch was even pushed to manually and has a tracking branch set up. I previously ran git push -u origin issue15108 which completed successfully.

Steps to reproduce the behavior

  1. Make changes and commit to repo
  2. Push topic branch to origin with tracking branch set up
  3. Run: gh pr create -w

Expected vs actual behavior

  • Expected: Browser is opened with my topic branch on my origin targeting master on upstream
  • Actual: Browser is opened with my topic branch name from upstream targeting master, and topic branch does not exist in upstream.

Logs

Nothing more was printed than what I typed above.

@heaths heaths added the bug Something isn't working label Sep 17, 2020
@mislav
Copy link
Contributor

mislav commented Sep 18, 2020

@heaths Thank you for reporting!

After you've pushed to origin, is there an origin/issue15108 tracking branch? gh was supposed to find that branch and realize that you've pushed to origin, not upstream. Not sure why that didn't happen, but the info you provided us is useful 🙇

@heaths
Copy link
Contributor Author

heaths commented Sep 18, 2020

Yes, I set the tracking branch on push.

@mislav
Copy link
Contributor

mislav commented Sep 18, 2020

@heaths Thank you! I will investigate this next week. Sorry for the trouble!

Protip: you can get more verbose logging with DEBUG=1, which will show the underlying git comands getting executed. Please paste us whatever you find interesting that way 🙇

@mislav mislav self-assigned this Sep 18, 2020
@vilmibm vilmibm added the needs-investigation CLI team needs to investigate label Sep 18, 2020
@heaths
Copy link
Contributor Author

heaths commented Sep 18, 2020

Thanks. I'll try to repro later. How can I undo the setting to set what I was prompted for? I figured that had something to do with it. A list verb on gh config would be nice (I'd be happy to contribute one if there's no reason not to add one).

@mislav
Copy link
Contributor

mislav commented Sep 22, 2020

@heaths The base repo setting can be reset with:

git config --unset remote.origin.gh-resolved

@vilmibm
Copy link
Contributor

vilmibm commented Sep 22, 2020

We have an issue for gh config list ( #859 ) but it's worth noting that here the relevant config is stored with git's config, something we do for per-repository settings.

I think in addition to anything like gh config list we ought to have a new help topic (like we did for env) that enumerates not just what gh supports internally but what config we rely on in git config.

@mislav mislav added this to Pending Release 🥚 in The GitHub CLI Sep 24, 2020
@mislav mislav moved this from Pending Release 🥚 to In progress 🚧 in The GitHub CLI Sep 24, 2020
The GitHub CLI automation moved this from In progress 🚧 to Done 💤 Sep 28, 2020
@heaths
Copy link
Contributor Author

heaths commented Oct 5, 2020

Could this also be the same problem that is causing gh pr create to fail to detect the upstream and origin branches? I just pushed my commit to origin, and even if I run gh pr create -w to do it manually, gh opens https://github.com/Azure/azure-sdk-for-net/compare/master...keyvaultproxy-sample?expand=1 - all against upstream.

git config --get remote.origin.gh-resolved shows nothing (not set); however, I do see it for upstream in .git/config:

[remote "upstream"]
	url = https://github.com/Azure/azure-sdk-for-net.git
	fetch = +refs/heads/*:refs/remotes/upstream/*
	gh-resolved = base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-investigation CLI team needs to investigate
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging a pull request may close this issue.

3 participants