diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index cdb91f8f7bb..36c40c75371 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -571,22 +571,9 @@ export class CommandCenter { const repositoryPath = await window.withProgress( opts, - (progress, token) => this.git.clone(url!, { parentPath: parentPath!, progress, recursive: options.recursive }, token) + (progress, token) => this.git.clone(url!, { parentPath: parentPath!, progress, recursive: options.recursive, ref: options.ref }, token) ); - const refToCheckoutAfterClone = options.ref; - if (refToCheckoutAfterClone !== undefined) { - await window.withProgress( - { - location: ProgressLocation.Notification, - title: localize('checking out ref', "Checking out ref '{0}'...", options.ref) - }, async () => { - await this.model.openRepository(repositoryPath); - const repository = this.model.getRepository(repositoryPath); - await repository?.checkout(refToCheckoutAfterClone); - }); - } - const config = workspace.getConfiguration('git'); const openAfterClone = config.get<'always' | 'alwaysNewWindow' | 'whenNoFolderOpen' | 'prompt'>('openAfterClone'); diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index c4db772afb1..d76eeebbc85 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -361,6 +361,7 @@ export interface ICloneOptions { readonly parentPath: string; readonly progress: Progress<{ increment: number }>; readonly recursive?: boolean; + readonly ref?: string; } export class Git { @@ -455,6 +456,9 @@ export class Git { if (options.recursive) { command.push('--recursive'); } + if (options.ref) { + command.push('--branch', `'${options.ref}'`); + } await this.exec(options.parentPath, command, { cancellationToken, env: { 'GIT_HTTP_USER_AGENT': this.userAgent },