How to configure options for the Version Control's git commit command

Viewed 4400

Is it possible to options for the Version Control's git commit command? If so, how? I'm a heavy user of the integrated source control UI in VS Code and I often need to provide extra options like --no-verify to the git commit. I still didn't figure out a way of doing this in VS Code.

Thanks!

2 Answers

With VSCode 1.50 (Sept 2020), there should now be more 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.

https://camo.githubusercontent.com/5c42dec32f31c5083e24299459693d5c9e5c9579/68747470733a2f2f692e696d6775722e636f6d2f585138304c57592e706e67


As illustrated with issue 110452, commit --no-verify will be in VSCode 1.52 (Nov. 2020)

Once you enablegit.allowNoVerifyCommit, a bunch of commands will be available:

https://user-images.githubusercontent.com/22350/98923649-38d3bf80-24d4-11eb-955a-5c9560dfbf76.png

Unfortunately, no

There is no way to pass arbitrary options to git commit in VSCode. The code that calls git commit is in git.ts, and it only passes a handful of fixed flags (some optionally).

Furthermore, although there are numerous VSCode extensions that enhance git in one way or another, none appears to intervene in calling git commit itself (those that do commits do so by ultimately calling into the built-in routine, from what I can tell).

Alternatives

One possible workaround would be to create your own git wrapper script and set git.path in settings.json to point at it. The wrapper script could take extra arguments from somewhere, perhaps via a custom extension; or maybe the "User Interface" is to simply edit that wrapper script when needed.

Related