keep-last-commit-message is a VS Code extension written in TypeScript that keeps the last Source Control commit message available for reuse in the current workspace.
- Reads and writes the last saved message through
ExtensionContext.workspaceState - Restores the message only when the Source Control input is empty
- Shares one saved message across all Git repositories in the same workspace
- Avoids restoring while Git is in special states such as merge, rebase, or cherry-pick
- Updates the saved message from the latest commit returned by
repository.log({ maxEntries: 1 })
keepLastCommitMessage.enabledkeepLastCommitMessage.restoreOnStartupkeepLastCommitMessage.restoreAfterCommit
This project can be packaged as a .vsix file and shared directly without publishing to the VS Code Marketplace.
- Install
vsce:npm install -g @vscode/vsce - Build the extension:
npm run compile - Generate the package:
vsce package - Share the generated
.vsixfile.
Reference: VS Code docs - Packaging Extensions
There are two common ways to install the packaged extension:
- In VS Code, open the Extensions view, select the
...menu, and chooseInstall from VSIX.... - From the command line, run:
code --install-extension keep-last-commit-message-0.0.1.vsix
- Open this folder in VS Code.
- Run
npm install. - Run
npm run compile. - Press
F5to launch a new Extension Development Host window. - Open a Git workspace in the development host and use Source Control commits to verify the behavior.