"Create Pull Request on Remote" does not target default branch
Description
When running "Create Pull Request on Remote" from a feature branch, the webpage that is opened targets "master" or "main" or probably whatever your first branch was called, instead of the default branch. Previously, the page that was opened targeted the default branch. I first noticed this today.
To reproduce:
- On GitHub, have a repository with a "master" or "main" branch, and then create one other branch, such as "dev".
- Set "dev" as the default branch on github. (New pull requests should target this branch.)
- In VS Code, create a new branch "feature", commit some changes, then push the branch to remote.
- Run "GitLens: Create Pull Request on Remote".
- The webpage that is opened targets "master" or "main", instead of the default "dev" branch.
GitLens Version
17.0.1
VS Code Version
Version: 1.98.2 Commit: ddc367ed5c8936efe395cffeec279b04ffd7db78 Date: 2025-03-12T13:32:45.399Z Electron: 34.2.0 ElectronBuildId: 11161602 Chromium: 132.0.6834.196 Node.js: 20.18.2 V8: 13.2.152.36-electron.0 OS: Linux x64 6.12.10-76061203-generic
Git Version
git version 2.34.1
Logs, Screenshots, Screen Captures, etc
Hi @ericman314 Thank you for your submissions, we see the problem and we are going to address it.
For now we can suggest the following workaround:
- update local HEAD ref, so it is sync with the remote:
git remote set-head origin -a - reload VS Code window, so the caches are cleared
That worked, thanks for the tip!
We use the origin/HEAD link to determine the target branch that, for GitHub.com, refers to the main branch on remote.
There are 2 points related to the current problem:
- When the main branch is updated on remote, usual
git pullorgit fetchdo not update theorigin/HEAD. For fixing itgit remote set-head origin -ais needed. So, here we can determine strategy or an event when we do such update. What events should it be? Maybe it can be any time we detect that the repo has been updated? - If we read
origin/HEADvalue once, then even if user manually updates the ref bygit remote set-head origin -a, we don't see it, because the value is cached incache.defaultBranchNameand never get updated. So, here we need a way to drop this cache sometimes as well. What events it should be? Probably, it could be based on expiration. Expire if after few seconds?
This ticket is waiting for the decision whether we are going to do anything on n.1. and n.2. and what strategy to use. cc @eamodio