There is now a VS Code extension that does the job: https://marketplace.visualstudio.com/items?itemName=srmeyers.git-prefix. By default, a click on the extension button will put into your commit message this label: "[YourBranchName]". Into the extension settings, there are 3 parameters if you want to fine tune the label (copy/paste from the extension page):
- gitPrefix.pattern: Regular expression pattern to match in the branch name. Default matches entire branch name.
- gitPrefix.patternIgnoreCase: Ignore case in pattern. Default is
false. - gitPrefix.replacement: Regular expression replacement string to place into commit message. Default is "[$1] ".