I am implementing the git template commit message for the team.
I've done it through .git/hooks/prepare-commit-msg
hook by
adding one line:
cat ".gitmessage" >> "$1"
Also I've configured the below:
git config --local commit.template .gitmessage
Well, the template feature works fine but only when git commit is called
without -m
flag.
Unfortunately, all the team members work flow is:
git add ...
git commit -m "Some message"
Question: How to force git to always open the editor to edit the message,
even when called by git commit -m ...
command?
The most common option used with git commit is the -m option. The -m stands for message. When calling git commit , it is required to include a message. The message should be a short description of the changes being committed. The message should be at the end of the command and it must be wrapped in quotations " " .
Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit. You can add a co-author by adding a trailer to the commit. For more information, see "Creating a commit with multiple authors."
To just edit a commit message (without adding new changes to your last commit), just run the amend command without adding changes. Simple as that!
The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!
-e opens the editor.
git commit -m "message" -e
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