【发布时间】:2022-02-11 21:16:57
【问题描述】:
我尝试像这样commit:
git commit --author='Paul Draper <my@email.org>' -m 'My commit message'
但我明白了:
*** 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.
我可以设置这些,但我在一个共享框上,之后我必须(想要)取消设置:
git config user.name 'Paul Draper'
git config user.email 'my@email.org'
git commit -m 'My commit message'
git config --unset user.name
git config --unset user.email
commit 的行数太多了!
有没有更短的方法?
【问题讨论】:
-
实际上并没有更短,但是如果您设置环境变量
GIT_COMMITTER_NAME和GIT_COMMITTER_EMAIL(以及相同的AUTHOR版本,或者像您一样使用--author参数),这应该足够了,你不需要--unset。 -
git config user.name "你的用户名在这里" git config user.email user@email.com
-
或者,这更短,可能更容易:
git -c user.name=... -c user.email=... commit ...
标签: git