如何以编程方式配置Git分支&x27;什么描述?

如何以编程方式配置Git分支&x27;什么描述?,git,config,stdin,git-branch,heredoc,Git,Config,Stdin,Git Branch,Heredoc,git分支--edit description命令打开一个文本编辑器,供用户手动输入git当前分支的描述 我所追求的是: git config branch.my_branch.description < <(fmt --width=72 <<MY_DESCRIPTION Subject (50 chars max) Intro (one sentence, line wraps after 72 chars) Description (multiple paragr

git分支--edit description
命令打开一个文本编辑器,供用户手动输入git当前分支的描述

我所追求的是:

git config branch.my_branch.description < <(fmt --width=72 <<MY_DESCRIPTION
Subject (50 chars max)

Intro (one sentence, line wraps after 72 chars)

Description (multiple paragraphs, line wraps after 72 chars)
MY_DESCRIPTION

git config branch.my_branch.description<您使用的
git config
是正确的。
--edit description
选项仅在默认(本地)git配置文件中设置
branch.branchname.description

(描述是转义序列编码的,但是
git-config
将为您提供此功能。)

在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
'
这就是诀窍。如果文件中有描述,例如
/tmp/file

$ git config branch.my_branch.description "$(cat /tmp/file)"
是的。显然,您可以将
cat
替换为任何其他命令,例如
fmt
,您可以使用以下文档:

$ git config branch.my_branch.description "$(cat << END)"
some lines

of text

that wind up in the description.
END

$git config branch.my_branch.description“$(cat)您的第一个和第二个建议有效。第三个建议带有
”$(cat@TimFriske:interest,一定是shell中的一些变体。/bin/sh行为正常,bash抱怨。将编辑。。。
cmd "$(cat << END
here-document text
goes here
END
)"