diff --git a/apps/sparo-lib/src/cli/commands/checkout.ts b/apps/sparo-lib/src/cli/commands/checkout.ts index 85e8492..49eb2ba 100644 --- a/apps/sparo-lib/src/cli/commands/checkout.ts +++ b/apps/sparo-lib/src/cli/commands/checkout.ts @@ -292,10 +292,16 @@ export class CheckoutCommand implements ICommand { }); const remoteFetchGitConfig: string[] | undefined = result?.split('\n').filter(Boolean); - // Prevents adding the same remote branch multiple times - const targetConfig: string = `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`; - if (remoteFetchGitConfig?.some((value: string) => value === targetConfig)) { - return; + if (remoteFetchGitConfig) { + const targetConfig: string = `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`; + if ( + // Prevents adding remote branch if it is not single branch mode + remoteFetchGitConfig.includes(`+refs/heads/*:refs/remotes/${remote}/*`) || + // Prevents adding the same remote branch multiple times + remoteFetchGitConfig?.some((value: string) => value === targetConfig) + ) { + return; + } } this._gitService.executeGitCommand({ diff --git a/apps/sparo-lib/src/cli/commands/fetch.ts b/apps/sparo-lib/src/cli/commands/fetch.ts index a4d3176..cea31a6 100644 --- a/apps/sparo-lib/src/cli/commands/fetch.ts +++ b/apps/sparo-lib/src/cli/commands/fetch.ts @@ -68,7 +68,7 @@ export class FetchCommand implements ICommand { private _revertSingleBranchIfNecessary = (remote: string): (() => void) | undefined => { let remoteFetchGitConfig: string[] | undefined = this._getRemoteFetchGitConfig(remote); let callback: (() => void) | undefined; - if (remoteFetchGitConfig) { + if (remoteFetchGitConfig && !remoteFetchGitConfig.includes(`+refs/heads/*:refs/remotes/${remote}/*`)) { this._setAllBranchFetch(remote); callback = () => {