10

Is there away to make VS Code automatically prepend branch name in commit message textarea?

Like if I'm on branch 'ID-7345' and just updated e.g. React.js version, I need to write:

ID-7345: updated React.js to version 16.0

and I would like to omit writing branch name each time there, so wherever I access this page I will see ID-7345: pre-populated and cursor blinking after it.

2 Answers 2

11

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] ".
Sign up to request clarification or add additional context in comments.

Comments

3

There is nothing to do on VS Code, use this https://git-scm.com/docs/githooks#_prepare_commit_msg or git template. Look at this also, can be helpful.

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.