2
我写了下面的bash函数,它应该用我的用户名硬编码创建一个提交。是的,我知道git config
,这只是一个最小的例子来证明我遇到的问题。内部脚本Git提交失败
# lib.sh
function lock-commit() {
local commit_author="Varun Madiath <[email protected]>"
git commit --author="${commit_author}" "[email protected]"
}
但是,当我运行这个,它给了我下面的错误。在命令行上直接运行该命令不会导致错误。
[[email protected] ac-test]$ source lib.sh
[[email protected] ac-test]$ lock-commit -m "test"
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <[email protected]>) not allowed
鉴于我明确地传递了作者,我应该不需要设置user.email
和user.name
配置设置。
任何想法为什么会发生这种情况,以及我如何纠正这种行为。
它适用于我。尝试将脚本裁剪为只调用'lock-function'或显示您的整个脚本,或者至少如何调用'lock-function'。 – Schwern
另外,你使用的是什么版本的Git?我相信' - 作者'并不总是在那里。 – Schwern
我使用git版本2.6.2。我已经更新了示例,但没有使用包装器scrpit,因此我直接调用了该函数。 –