microsoft/vscode · error · Error

Could not find the repository for branch '{0}'.

Error message

Could not find the repository for branch '{0}'.

What it means

Error "Could not find the repository for branch '{0}'." thrown in microsoft/vscode.

Source

Thrown at extensions/copilot/src/extension/chatSessions/vscode-node/pullRequestCreationService.ts:64

export class PullRequestCreationService extends Disposable implements IPullRequestCreationService {
	declare readonly _serviceBrand: undefined;

	constructor(
		@IInstantiationService private readonly instantiationService: IInstantiationService,
		@IGitService private readonly gitService: IGitService,
		@IOctoKitService private readonly octoKitService: IOctoKitService,
	) {
		super();
	}

	async createPullRequest(options: CreatePullRequestOptions, token: vscode.CancellationToken): Promise<string | undefined> {
		const { repositoryUri, branchName, baseBranchName, isDraft } = options;

		const repository = await this.gitService.openRepository(repositoryUri);
		const repositoryContext = await this.gitService.getRepository(repositoryUri);

		if (!repository || !repositoryContext) {
			throw new Error(l10n.t('Could not find the repository for branch \'{0}\'.', branchName));
		}

		// Resolve owner/repo from the (preferred upstream's) remote.
		const githubRepoInfo = getGitHubRepoInfoFromContext(repositoryContext);
		const remoteInformation = githubRepoInfo
			? repository.state.remotes.find(remote =>
				githubRepoInfo.remoteUrl === remote.fetchUrl || githubRepoInfo.remoteUrl === remote.pushUrl)
			: undefined;

		if (!githubRepoInfo || !remoteInformation) {
			throw new Error(l10n.t('Could not determine the GitHub remote for branch \'{0}\'.', branchName));
		}

		// Push the branch (set upstream when missing).
		const head = repository.state.HEAD;
		const setUpstream = !head?.upstream;
		await repository.push(remoteInformation.name, branchName, setUpstream);

View on GitHub (pinned to a94b963a32)

When it happens

Trigger: Thrown at extensions/copilot/src/extension/chatSessions/vscode-node/pullRequestCreationService.ts:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12). Data as JSON: /api/errors/ce6b5f408f9233f8. Report an issue: GitHub.