gitvisual-studio-code

How can I change when Git commit message length warning appears in VS Code?


enter image description here

Is there a way to get VS Code to automatically adjust the commit line message to avoid this warning. Otherwise I need to pay attention and press enter when the message appears, every time I write a commit message.

I would want VS Code to automatically press enter for me , I really don't even understand why the warning shows up, never had that issue when using SourceTree UI for example


Solution

  • If you want to just change the threshold for showing the warning, use "git.inputValidationSubjectLength": <N> for the subject line (the first line) and "git.inputValidationLength": <N> for subsequent lines.

    If you want to turn the validation off entirely, use "git.inputValidation": "off". Note that in VS Code 1.85, the default value of the setting was changed to "off", so now you need to also manually set it to "always" or "warn". In VS Code 1.87, the setting itself was changed to a boolean where false is off and true is on.

    Put these settings in your settings.json file.

    The worst that can happen if you have long subject lines for your commit messages is that it will be hard for you and others to quickly know what a commit has changed. Nothing will explode, but you'll probably thank yourself in the future if you make an effort to be concise. See also: Git Commit Messages: 50/72 Formatting.

    See also the git docs on the commit command:

    Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git.


    Note also that you can set editor rules for the editor if you use the commit editor:

    "[git-commit][scminput]": {
    // [git-commit] for commit editor, [scminput] for SCM View input box
        "editor.rulers": [72,50],
        "editor.wordWrap": "wordWrapColumn", // or "off"
        "editor.wordWrapColumn": 72,
    },
    

    scminput is only supported in VS Code 1.86+, and only makes sense if you use a monospace font in scm.inputFontFamily.