Sample Header Ad - 728x90

Change the default comments in GIT's COMMIT_EDITMSG after typing "git commit"

4 votes
3 answers
4394 views
Sometimes when I'm at work, I want to commit and push changes to my own projects on GitHub. So I do a lot of git config user.email to make sure that I don't *commit* with my email at the company and that I in fact use my own personal email. Now I have export GIT_EDITOR=vim in my ~/.zshrc file, so that every time I type git commit, vim opens up and I see a file like this:
my actual commit message
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#         modified:    vim/.vimrc
#
Is there a way that I can modify these comments? So that it shows something like this:
my actual commit message
# Email: me@my.site
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#         modified:    vim/.vimrc
#
Asked by Amir Shabani (291 rep)
Feb 12, 2022, 01:16 PM
Last activity: Oct 14, 2023, 01:11 AM