Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force "git commit -m" to open editor

Tags:

git

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?

like image 308
KostaZ Avatar asked Oct 20 '15 12:10

KostaZ


People also ask

What is M in git commit?

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 " " .

How do I commit to github editor?

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."

How do I edit an already pushed commit?

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!

How do I change the default git bash editor?

The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!


1 Answers

-e opens the editor.

git commit -m "message" -e
like image 146
Dirigible Avatar answered Sep 28 '22 02:09

Dirigible