3
有没有可能改变默认格式Signed-off-by
行。Git签名自定义格式
默认情况下是:
Signed-off-by: user.name <user.email>
有些项目需要其他格式,如:
Signed-off-by: user.name <user.email> (github: account_name)
有没有可能改变默认格式Signed-off-by
行。Git签名自定义格式
默认情况下是:
Signed-off-by: user.name <user.email>
有些项目需要其他格式,如:
Signed-off-by: user.name <user.email> (github: account_name)
由于max630的评论我准备简单挂钩:
#!/bin/sh
NAME=`git config user.name`
EMAIL=`git config user.email`
GITHUB=`git config user.github`
if [ -z "$NAME" ]; then
echo "empty git config user.name"
exit 1
fi
if [ -z "$EMAIL" ]; then
echo "empty git config user.email"
exit 1
fi
if [ -z "$GITHUB" ]; then
echo "empty git config user.github"
exit 1
fi
git interpret-trailers --trailer \
"Signed-off-by: $NAME <$EMAIL> (github: $GITHUB)" \
--in-place "$1"
为了使用它,请在您的项目中输入以上代码:.git/hook/prepare-commit-msg
。
您还需要添加这个脚本中使用git的配置,可以为项目做到这一点:
git config user.github "<user github login>"
或globaly设置:
git config --global user.github "<user github login>"
配置项user.name
和user.email
最有可能你已经。
您应该使用[prepare-commit-msg hook](https://www.kernel.org/pub/software/scm/git/docs/githooks.html#_prepare_commit_msg)更新消息。您可以找到有用的[git interpret-trailers](https://www.kernel.org/pub/software/scm/git/docs/git-interpret-trailers.html)命令来处理预告片条目 – max630