'Is there a way to instruct Visual Studio Code to skip git commit hooks (i.e., to supply the -n argument)?

I would like to be able to install a pre-commit hook, but also to be able to commit under certain circumstances (e.g., WIP) even when the hook fails. I can do this easily from the command line, using git commit --no-verify (git commit -n). But I can't find anything that allows me to affect the commit in VSCode other than the text field for the commit message.

Am I missing it, or is it not there?



Solution 1:[1]

Is there a way to instruct Visual Studio Code to skip git commit hooks (i.e., to supply the -n argument)?

Update Sept 2020: there is, with VSCode 1.50 (Sept 2020), which adds the missing option for git commit in VSCode.

See PR 106335: Adds commands for --no-verify commit variants

This PR adds *NoVerify command variants for creating commits while skipping pre-commit and commit-msg hooks.

The commands are only displayed if the git.allowNoVerifyCommit option is set to true.
This type of commits requires additional confirmation (like git.pushForce does), which can be bypassed by disabling the git.confirmNoVerifyCommit option.

See the (now released) VSCode 1.50 "Git: Commit --no-verify commands"

Git commit commands with the --no-verify flag are now available after enabling the git.allowNoVerifyCommit setting.

git --no-verify in command palette -- https://code.visualstudio.com/assets/updates/1_50/git-no-verify.png


Original answer Dec. 2019: From VSCode alone:

From a VSCode extension, like GitLens

  • there is no such option even in its issues: this has not been requested before.

Solution 2:[2]

Enable No Verify Commits

Go into VSCode settings and enable: git.allowNoVerifyCommit

"git.allowNoVerifyCommit": true

Profit

Source Control Panel

Now you can use the: Commit (No Verify) option through the Source Control panel.

Git commit no verify through source control panel.

Command Palette

Or you can use it through the Command Palette.

Git commit no verify through command palette.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 CTS_AE