How to commit an optional extended description from command line (Git Bash) – 007

As you saw from previous posts, the UI on GitHub.com allows you to specify an optional extended message.

Commit new file - Add an optional extended description edit field

If you fill this optional extended description out,

Added a newline as demanded by markdown - extended description shown

you’ll see your extended description comments behind the `…` ellipsis.

ellipsis as a button on the commit message

Clicking the ellipsis shows the optional extended description.

extended description showing behind ellipsis

How to do add the extended description from the command line

I’ve looked at a few stack overflow answers. There are answers using  two -m arguments, using a literally formatted string (i.e. the ‘$’ at the start of the string), and using a vim editor. This also works for other editors I’ve played with.

For my examples right now, you’re watching me use Git Bash (i.e. Git Shell as setup from Desktop for Windows – I’ll cover more about Desktop for Windows in the upcoming tips).

Using the two -m arguments approach,

git commit message with two -m parameters

and pushing that up to GitHub, you’ll see the optional extended description under the ellipsis.

github.com showing the extended description from command line

Old SDETs never die! What if I added 3 -m arguments?? What will GitHub do?

git commit message with three -m parameters

Looks like each extra -m adds a newline  in the optional extended description, as shown on GitHub.com.

github.com showing a commit message with a newline in description

Leave a comment