Skip to content

Conversation

@bstaeheli
Copy link

Summary

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.

Changes

Modified the push() function in extensions/git/src/repository.ts to check the push.default Git configuration. If set to current, it uses only the branch name (pushing to a remote branch of the same name) rather than the full refspec localBranch:upstreamBranch.

Fixes #182510

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
Copilot AI review requested due to automatic review settings December 5, 2025 10:56
@vs-code-engineering
Copy link

vs-code-engineering bot commented Dec 5, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/repository.ts

Copilot finished reviewing on behalf of bstaeheli December 5, 2025 11:05
Copy link
Contributor

Copilot AI left a 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 the push.default Git configuration setting
  • When set to current, uses only the branch name instead of the full refspec

Comment on lines 2082 to 2088
// 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}`;
}
Copy link

Copilot AI Dec 5, 2025

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:

  1. Push behavior when push.default=current is set (should use head.name as branch)
  2. Push behavior when push.default is unset or set to other values (should use head.name:head.upstream.name)
  3. Push behavior when config read fails (returns empty string)

Copilot uses AI. Check for mistakes.
@bstaeheli
Copy link
Author

@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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git - Support the "push.default=current" strategy

3 participants