-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Respect push.default=current configuration in push command #281486
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
base: main
Are you sure you want to change the base?
Respect push.default=current configuration in push command #281486
Conversation
When push.default=current is set in Git configuration, push to a remote branch with the same name as the local branch instead of pushing to the configured upstream branch. Fixes microsoft#182510
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for Git's push.default=current configuration option to respect the user's Git config preference when pushing changes. Currently, VS Code always pushes to the configured upstream branch using the refspec format localBranch:upstreamBranch. With this change, when push.default=current is set, it will push to a remote branch with the same name as the local branch.
Key Changes:
- Modified the
push()method to check thepush.defaultGit configuration setting - When set to
current, uses only the branch name instead of the full refspec
| // Respect push.default=current configuration | ||
| const pushDefault = await this.repository.config('get', '', 'push.default'); | ||
| if (pushDefault === 'current') { | ||
| branch = head.name; | ||
| } else { | ||
| branch = `${head.name}:${head.upstream.name}`; | ||
| } |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new push.default=current configuration handling lacks test coverage. Consider adding tests to verify:
- Push behavior when
push.default=currentis set (should usehead.nameas branch) - Push behavior when
push.defaultis unset or set to other values (should usehead.name:head.upstream.name) - Push behavior when config read fails (returns empty string)
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
When
push.default=currentis set in Git configuration, push to a remote branch with the same name as the local branch instead of pushing to the configured upstream branch.Changes
Modified the
push()function inextensions/git/src/repository.tsto check thepush.defaultGit configuration. If set tocurrent, it uses only the branch name (pushing to a remote branch of the same name) rather than the full refspeclocalBranch:upstreamBranch.Fixes #182510