106

I recently use GitHub and downloaded GitHub for Mac.

I noticed you can add an 'extended description' using GitHub for Mac. How do I add an extended description using the command line?

Can I add an extended description to an existing commit?

questionto42
  • 7,175
  • 4
  • 57
  • 90
Adrian Gunawan
  • 13,979
  • 11
  • 40
  • 41

3 Answers3

124

Run git commit without a message and it'll open up your favorite* text editor to write a commit message. Details on the format of the message will appear in the sample.

First line is the short description. Leave a blank line after it. Everything else is the extended description.

*: for some values of "favorite"; results may vary

Stephan Dollberg
  • 32,985
  • 16
  • 81
  • 107
  • 1
    Can i add both short description and extended description just like in the GitHub for Mac? I'm thinking of adding short description like 'bug fixes' and extended description on the bugs that was fixed.. – Adrian Gunawan Mar 05 '12 at 09:11
  • 4
    @NickM, you should be able to run `git config --global core.editor nano` and it will configure git to use nano as your default editor. Replace "nano" with "emacs", "vim" or whatever your preference is. – arnaslu Mar 22 '15 at 08:50
  • 2
    @arnaslu Or `export EDITOR=nano` in your shell profile; this will affect a number of other command-line tools that use an external editor. –  Mar 22 '15 at 17:19
122

From this accepted answer:

git commit -m "Title" -m "Description .........."
R.F
  • 335
  • 3
  • 8
1j01
  • 3,714
  • 2
  • 29
  • 30
61

Actually, you can do this quite easily from the command line. The trick is to type your message (without a closing quote!) and then hit enter twice, and then type your extended message, close the quote and press enter.

It should look like:

$ git commit -m "Make everything work.
dquote>
dquote> Add magic code that fixes everything"

GitHub will correctly display the top line as your basic message and the bottom line as the extended message.

The following does NOT work. You end up with the literal "\n\n" in the commit message: $ git commit -m "Basic msg\n\nExtend msg, doesnt work".

stephen.hanson
  • 9,014
  • 2
  • 47
  • 53