40 git git-config git-commit git-commands
我第一次使用git并设置了用户名和用户邮件.我使用的命令如下:
git config --global user.email "bob@example.com"
git config user.email "bob@example.com"
git config --global user.name "bob"
git config user.name "bob"
Run Code Online (Sandbox Code Playgroud)
当我跑步时git commit --author "bob"
,我收到了一个错误fatal: No existing author found with 'bob'
.如何设置用户名和电子邮件?
mea*_*gar 45
您应该在--author
每次提交时停止使用,而是使用配置作者git config
.完成后,您可以输入git commit
并从.gitconfig
文件中提取作者.
如果要提供--author
用于创作提交的名称,则需要使用
bob <bob@example.com>
不只是bob
.如果您的作者字符串与user <user@example.com>
格式不匹配,Git假定您已经为其提供了搜索模式,并且它将尝试查找具有匹配作者的提交.它将使用第一个找到的提交user <user@example.com>
作为作者.
Iva*_*lin 13
这个命令可以解决这个问题:
git commit --amend -C HEAD --reset-author
Run Code Online (Sandbox Code Playgroud)
注意:从 Git 2.3.1+(2015 年第一季度/第二季度)开始,错误消息将更加明确。
见提交1044b1f由迈克尔·格鲁伯Ĵ( )mjg
:
commit
: 改写--author
错误信息
如果
--author
指定了参数但不包含“>
”,则 git 尝试在现有作者中查找参数;No existing author found with '%s'
如果没有匹配项,则给出错误消息“ ”。
这对于尝试指定有效的完整作者姓名的用户来说是令人困惑的。
重命名错误消息以更清楚地表明在这种情况下失败有两个原因。
解决方案仍然是正确设置配置 user.name 和 user.email,但对于使用的情况--author
,至少预期的参数现在更清晰。
所以运行:
git add --all ; git commit -m "$git_msg" \
--author "First Last <first.last@company.com>"; git push
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
43262 次 |
最近记录: |