C
C#7mo ago
cow

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
mg
mg7mo ago
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
cow
cowOP7mo ago
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
mg
mg7mo ago
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
cow
cowOP7mo ago
cool as, it works through Visual Studio
cow
cowOP7mo ago
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.
mg
mg7mo ago
👍 I love git hooks I love git in general
cow
cowOP7mo ago
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
mg
mg7mo ago
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
Want results from more Discord servers?
Add your server