Prepend string to git commit messages via VS2022 git interface?
I want to prepend a string to each of my commits. Is this possible?
I've been searching and it looks like you can achieve it with "git hooks", but git hooks are not supported with Visual Studio?
My end goal is to have Jira ticket number prepended to each commit, but I need to start with just figuring how to prepend a basic string.
Thanks
8 Replies
git hooks are a part of git; your choice of IDE shouldn't matter
You should still be able to edit the prepare-commit-msg hook and it should still run when committing from VS
Unless VS overwrites the commit message for some reason, but I doubt it does
oh i see, maybe the things i was reading were old, but they said it fails if you commit via VS
i'll give it a try though
They could be right, I'm not sure and I don't use VS
But yeah give it a shot and see
If it does, I'd encourage using git from the command line anyway. It's a good skill to have
cool as, it works through Visual Studio
git hook - prefix your commit message with your JIRA ticket
In this short blog post I'll show you how you can automatically prefix your commit messages with the JIRA ticket derived from your branch name.
👍
I love git hooks
I love git in general
What kinda things are you doing with git hooks? I didn't know they existed until today, very curious to know what useful things other people are doing with them
Not a whole lot as my projects don't require that much, but one common use case is running tests in a pre-commit hook
Or building the project in the pre-commit hook to make sure whatever you're committing compiles
Though that's more of a CI responsibility