Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting GitHub commit messages from shell

I just read Writing good commit messages and liked it a lot. The problem is, I prefer the command line (plain ole' git).

  • How can I add newlines and tabs to commit messages, so as to have a "summary line" and message body (which may consist of several paragraphs)?
  • Does GitHub support markdown in their commit messages? After reading "Shiny new commit styles" this doesn't seem possible
like image 643
smeeb Avatar asked Mar 13 '15 16:03

smeeb


2 Answers

  1. For newline, just hit enter inside quotes, like this: git commit -m "Some headline <hit enter>. Also you can use your text editor to write commit messages.

  2. Unfortunately no, e.g. this commit with markdown for example.

like image 193
Tomas Votruba Avatar answered Sep 30 '22 19:09

Tomas Votruba


git automatically spawns your preferred $EDITOR to prompt for a commit message when you run git commit. So it may be as simple as leaving -m off of your git commit command

If git launches the wrong editor, or fails to launch an editor, try setting the EDITOR environment variable to your preferred editor:

export EDITOR=/usr/bin/vim

Or, to only change the editor used by git, you can set core.editor

git config --global core.editor /usr/bin/vim

Using an editor to compose a commit message this way has a couple of further advantages. Git populates the file you are editing with a summary of the files that were changed in the commit, which should help you write a better commit message. Also, vim (and other editors) support basic syntax highlighting for this kind of file, making it even easier.

like image 26
ComputerDruid Avatar answered Sep 30 '22 19:09

ComputerDruid