The company I work for is imposing some requirements on our git messages. Our branch names follow the format <branch_type>/<jira_ticket><arbitrary>
. We are required to prepend our commit messages with <jira_ticket>
.
I would like to add a custom option to git commit
, -p
, that makes a commit with the current branch's jira_ticket
prepended to the commit message. Ideally I would like the option to work such that:
git commit -p "my commit message" [OTHER_ARGS]
Gets executed as:
git commit -m "<jira_ticket> my commit message" [OTHER_ARGS]
Furthermore, if I simply execute git commit -p [OTHER_ARGS]
where -m
is not in OTHER_ARGS
, I'd like my configured text editor to pop up with "<jira_ticket>
" prefilled and ready for me to append to (akin to the functionality of executing git commit
with no -m
).
Does git have built in functionality for adding custom options like this? If not, what approach should I take to this problem?