我没有 git 用户数据集:
$ git commit -m '...'
*** 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: empty ident name (for <...>) not allowed
Run Code Online (Sandbox Code Playgroud)
如果我运行这些命令,我的用户数据将被全局设置。我只想为一次提交设置用户数据。
是否有任何参数可以传递git commit给设置用户数据?
该--author标志将设置作者,但您还必须设置提交者姓名和电子邮件。
没有用于此的命令行标志,但是如果设置了环境变量,git 将使用环境变量:GIT_COMMITTER_NAME和GIT_COMMITTER_EMAIL。
假设一个 sh/bash 风格的 shell:
GIT_COMMITTER_NAME='A U Thor' \
GIT_COMMITTER_EMAIL='author@example.example' \
git commit --author 'A U Thor <author@example.example>' ...
Run Code Online (Sandbox Code Playgroud)
应该这样做。
或者,您可以在 git 全局配置中设置这些,然后删除它们(用于git config --global -e在文件上运行您喜欢的编辑器,如果您不想摆弄git config --unset)。
编辑:或者,您可以使用 临时配置它们git -c name=value,例如:
git -c user.name='A U Thor' -c user.email=author@example.example commit ...
Run Code Online (Sandbox Code Playgroud)
请注意(与环境变量一样)这将覆盖任何文件配置值。