当我这样做时:
cd /home/erelsgl/git/erel-sites; git commit -m "test"
Run Code Online (Sandbox Code Playgroud)
我得到正确的:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
但是,当我将同一行放在我帐户的 crontab 中时,我在日志文件中看到:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
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: unable to auto-detect email address (got 'erelsgl@erelsgl-computer')
Run Code Online (Sandbox Code Playgroud)
我在 crontab 中输入了“whoami”并得到了与外部相同的答案(“erelsgl”)。
我还尝试将推荐的“git config --global”命令放在 crontab 中(我已经在 crontab 外成功运行了它们),但这没有帮助。
我应该怎么做才能从 crontab 提交?
git 需要在其配置文件之一或环境变量中查找user.email
和。user.name
您有更多选项可以让 git 获取这些值。显然,当从 crontab 调用时,git 不会使用某些配置文件。
我建议您从两个选项中进行选择:
1. 使用命令将user.email
和user.name
放入存储库的配置中
git config user.email "you@example.com"
git config user.name "Your Name"
Run Code Online (Sandbox Code Playgroud)
执行此操作时,您应该位于存储库中。这样,存储库配置文件.git/config
将设置值,并且提交应该可以从 crontab 进行。您可以检查
cat .git/config
Run Code Online (Sandbox Code Playgroud)
2.设置环境变量,帮助git获取缺失值。在这种情况下,我会运行这样的命令
cd /home/erelsgl/git/erel-sites; GIT_COMMITTER_NAME="Your Name" GIT_COMMITTER_EMAIL="you@example.com" git commit -m "test"
Run Code Online (Sandbox Code Playgroud)
我认为变量 GIT_AUTHOR_NAME 和 GIT_AUTHOR_EMAIL 也应该起作用。
我在以下页面上找到了此信息:
小智 1
而不是--global
,尝试--system
sudo git config --system user.email "you@example.com"
sudo git config --system user.name "Your Name"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2100 次 |
最近记录: |