You're on the right track with git config
. The --edit-description
option just sets branch.branchname.description
in the default (local) git config file.
(The description is escape-sequence-encoded, but git config
will do that for you.)
In shell-ese:
$ git config branch.my_branch.description 'Subject (50 chars max)
Intro (one sentence, line wraps after 72 chars)
Description (multiple paragraphs, line wraps after 72 chars)
MY_DESCRIPTION
'
does the trick. If you have a description in a file, such as /tmp/file
:
$ git config branch.my_branch.description "$(cat /tmp/file)"
does it. Obviously you can replace cat
with any other command, such as fmt
, and you may use here-documents:
$ git config branch.my_branch.description "$(cat << END)"
some lines
of text
that wind up in the description.
END
(in my testing the encoded config entry for this last one does not end in a newline, but that seems to be OK, even though the other versions do end in a newline).
Edit: bash does not like the above here-document syntax; this seems to work:
cmd "$(cat << END
here-document text
goes here
END
)"
in both bash and /bin/sh, on my test system.