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,因此我直接調用了該函數。 –