'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 (likegit.pushForce
does), which can be bypassed by disabling thegit.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 thegit.allowNoVerifyCommit
setting.
Original answer Dec. 2019: From VSCode alone:
- there is no such option in
extensions/git/src/git.ts
(but its could be amended by a patch, if a contributor might chose to)
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.
Command Palette
Or you can use it through the 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 |