Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set nano up for git commit messages with line length limits

Tags:

git

nano

I use nano for git commit messages. Short summary (<=50 chars) plus a new line before the description is relatively straightforward to stick to. However, when it comes to wrapping at 72 chars in the description body I just go off what seems to look right, making for inconsistent logs.

In Vagrantfiles I've seen this sort of thing to tell the editor what to do for vi/vim:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Is there something like that for nano, and a template somewhere for git commit, that means I can ensure that nano would be set up for the correct line wrapping when in the context of a git commit message?

like image 747
bcmcfc Avatar asked Feb 13 '17 10:02

bcmcfc


People also ask

Is there a limit to a git commit message?

The maximum lengths of the subject and message body can be configured in the standard Gerrit config file gerrit. config . The defaults are 50 characters for the summary and 72 characters for the description, as recommended by the git tutorial and expanded upon by Tim Pope.

How long should git commit messages be?

Length: The first line should ideally be no longer than 50 characters, and the body should be restricted to 72 characters. Content: Be direct, try to eliminate filler words and phrases in these sentences (examples: though, maybe, I think, kind of).


1 Answers

Nano supports the passing of command line arguments when starting it.

This can be leveraged as part of the git editor config setting.

git config --global core.editor "nano -r 72"

Or:

export GIT_EDITOR='nano -r 72'

like image 90
bcmcfc Avatar answered Sep 29 '22 01:09

bcmcfc