diff --git a/extensions/git/src/actionButton.ts b/extensions/git/src/actionButton.ts index 5dd42eebdd5..7f431c4cd44 100644 --- a/extensions/git/src/actionButton.ts +++ b/extensions/git/src/actionButton.ts @@ -219,6 +219,16 @@ export class CommitActionButton extends AbstractActionButton { }; } + // Not a branch (tag, detached) + if (this.state.HEAD?.type === RefType.Tag || !this.state.HEAD?.name) { + return { + command: 'git.commit', + title: l10n.t('{0} Commit', '$(check)'), + tooltip: this.state.isCommitInProgress ? l10n.t('Committing Changes...') : l10n.t('Commit Changes'), + arguments: [this.repository.sourceControl, ''] + }; + } + // Commit return this.postCommitCommandCenter.getPrimaryCommand(); } @@ -229,6 +239,11 @@ export class CommitActionButton extends AbstractActionButton { return []; } + // Not a branch (tag, detached) + if (this.state.HEAD?.type === RefType.Tag || !this.state.HEAD?.name) { + return []; + } + // Commit const commandGroups: Command[][] = []; for (const commands of this.postCommitCommandCenter.getSecondaryCommands()) {