How do I craft customized commit message template?
I would like to have something like:
# Short (50 chars or fewer) summary of changes
# More detailed explanatory text
Add following to your ~/.gitconfig
:
[commit]
template = ~/.git-commit-message
Create ~/.git-commit-message
file with following content:
# Short (50 chars or fewer) summary of changes
# More detailed explanatory text
Ref. commit.template in http://git-scm.com/docs/git-config
The value in creating a custom commit template is that you can use it to remind yourself (or others) of the proper format and style when creating a commit message.
There are 3 easy steps you will need to set so that you can follow same format whenever you (or others) do commit using: git commit
1) You'll need to add your editors .exe file using git command
git config --global core.editor "your editor full path" (ex: C:/Windows/notepad.exe)
Note: Run git as administrator
2) Now add your template text in one file and save it at your preferred location( you can save it anywhere in your machine) using some name .txt (ex : commit_template.txt)
Your custom commit message may be like
Subject line (try to keep under 50 characters)
Multi-line description of commit,
feel free to be detailed.
[Ticket: X]
Resolves : #121, #12
3) Set your template as default and custom commit template by adding this command:
git config --global commit.template "path of txt file" (ex: D:/My Commit Template/commit_template.txt)
If your team has a commit-message policy, then putting a template for that policy on your system and configuring Git to use it by default can help increase the chance of that policy being followed regularly.
Thank You!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With