Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ba141a3
Add `Git: Delete` action to run `git rm` command on the current docu…
dmitrivMS Dec 30, 2025
2b429c4
Update extensions/git/src/commands.ts
dmitrivMS Dec 30, 2025
a37bafb
Fix incorrect Copilot change.
dmitrivMS Dec 30, 2025
ebebf53
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Dec 31, 2025
e893ac5
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 5, 2026
29dd5b8
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 6, 2026
c104aae
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 6, 2026
73a2b04
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 7, 2026
8dc3840
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 7, 2026
7b4619f
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 8, 2026
910d051
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 8, 2026
881ead2
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 9, 2026
9eb73d4
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 9, 2026
e2704f6
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 10, 2026
22feee9
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 11, 2026
7483d81
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 12, 2026
66e9ae8
PR feedback
dmitrivMS Jan 12, 2026
19057ae
Fix condition
dmitrivMS Jan 12, 2026
9fe157f
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 12, 2026
0ff25ff
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 13, 2026
129e6bc
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 16, 2026
c3e1bc5
Merge branch 'main' into dev/dmitriv/git-delete-command
dmitrivMS Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@
"icon": "$(discard)",
"enablement": "!operationInProgress"
},
{
"command": "git.delete",
"title": "%command.delete%",
"category": "Git",
"icon": "$(trash)",
"enablement": "!operationInProgress"
},
{
"command": "git.commit",
"title": "%command.commit%",
Expand Down Expand Up @@ -1297,6 +1304,10 @@
"command": "git.rename",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && resourceScheme == file && scmActiveResourceRepository"
},
{
"command": "git.delete",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && resourceScheme == file"
},
{
"command": "git.commit",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
Expand Down Expand Up @@ -3303,6 +3314,11 @@
"description": "%config.confirmSync%",
"default": true
},
"git.confirmCommittedDelete": {
"type": "boolean",
"description": "%config.confirmCommittedDelete%",
"default": true
},
"git.countBadge": {
"type": "string",
"enum": [
Expand Down
2 changes: 2 additions & 0 deletions extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"command.unstageChange": "Unstage Change",
"command.unstageSelectedRanges": "Unstage Selected Ranges",
"command.rename": "Rename",
"command.delete": "Delete",
"command.clean": "Discard Changes",
"command.cleanAll": "Discard All Changes",
"command.cleanAllTracked": "Discard All Tracked Changes",
Expand Down Expand Up @@ -167,6 +168,7 @@
"config.autofetch": "When set to true, commits will automatically be fetched from the default remote of the current Git repository. Setting to `all` will fetch from all remotes.",
"config.autofetchPeriod": "Duration in seconds between each automatic git fetch, when `#git.autofetch#` is enabled.",
"config.confirmSync": "Confirm before synchronizing Git repositories.",
"config.confirmCommittedDelete": "Confirm before deleting committed files with Git.",
"config.countBadge": "Controls the Git count badge.",
"config.countBadge.all": "Count all changes.",
"config.countBadge.tracked": "Count only tracked changes.",
Expand Down
35 changes: 35 additions & 0 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,41 @@ export class CommandCenter {
await commands.executeCommand('vscode.open', Uri.file(path.join(repository.root, to)), { viewColumn: ViewColumn.Active });
}

@command('git.delete')
async delete(uri: Uri | undefined): Promise<void> {
const activeDocument = window.activeTextEditor?.document;
uri = uri ?? activeDocument?.uri;
if (!uri) {
return;
}

const repository = this.model.getRepository(uri);
if (!repository) {
return;
}

Comment thread
dmitrivMS marked this conversation as resolved.
const allChangedResources = [
...repository.workingTreeGroup.resourceStates,
...repository.indexGroup.resourceStates,
...repository.mergeGroup.resourceStates,
...repository.untrackedGroup.resourceStates
];

// Check if file has uncommitted changes
const uriString = uri.toString();
if (allChangedResources.some(o => pathEquals(o.resourceUri.toString(), uriString))) {
window.showInformationMessage(l10n.t('Git: Delete can only be performed on committed files without uncommitted changes.'));
return;
}

await repository.rm([uri]);

// Close the active editor if it's not dirty
if (activeDocument && !activeDocument.isDirty && pathEquals(activeDocument.uri.toString(), uriString)) {
await commands.executeCommand('workbench.action.closeActiveEditor');
}
}

@command('git.stage')
async stage(...resourceStates: SourceControlResourceState[]): Promise<void> {
this.logger.debug(`[CommandCenter][stage] git.stage ${resourceStates.length} `);
Expand Down
Loading