fix(git): use configured push target for Push and Sync#323650
Draft
AbdelrahmanHafez wants to merge 5 commits into
Draft
fix(git): use configured push target for Push and Sync#323650AbdelrahmanHafez wants to merge 5 commits into
AbdelrahmanHafez wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the built-in Git extension’s default Push and Sync behavior to stop constructing an explicit remote refspec from the upstream branch, and instead delegate push-target selection to Git’s own configuration (push.default, remote.pushDefault, triangular workflow), while keeping the pull/rebase side of Sync explicitly tied to the upstream branch.
Changes:
- Default Push and the push-half of Sync now run without an explicit remote/refspec so Git decides the destination.
- Sync UI messaging (confirmation + tooltip) no longer claims pushes go to the upstream branch.
- Adds Git integration tests covering
push.default=current,remote.pushDefault, and “read-only upstream + configured push remote”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| extensions/git/src/test/push.test.ts | Adds integration tests validating Push/Sync respect Git’s configured push destination (including read-only upstream scenarios). |
| extensions/git/src/repository.ts | Changes Push/Sync push execution to omit remote/refspec and updates Sync tooltip/label behavior accordingly. |
| extensions/git/src/commands.ts | Updates Sync confirmation prompt copy and removes upstream-remote read-only gating for prompting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #137686, fixes #182510, fixes #158644
The issue was that the Git extension was treating the upstream branch as the push target. For a local branch named
featurethat tracksupstream/main, VS Code would explicitly run the equivalent of:That bypasses Git's normal push destination logic. In practice that means VS Code could ignore
push.default=simple,push.default=current,remote.pushDefault, and triangular workflow config, and it could push a feature branch intomaineven though plaingit pushwould either push somewhere else or refuse.I've been personally burned by this multiple times where I had to revert PRs accidentally merged to main while working on git worktrees on other branches.
This PR:
HEAD.name:HEAD.upstream.namefor the regular Push commandpush.default=current,remote.pushDefault, and a read-only upstream remote with a configured push remoteThis does not change explicit push commands like Push To, Publish Branch, Push Tags, or commands where the user explicitly picked a remote/refspec. It only changes the default Push/Sync path to line up with what Git would do for
git push.I also verified the failure mode before the implementation: the new tests failed because VS Code pushed
feature:mainto the upstream remote. All tests fail for the right reasons, and pass after the changes.