gpt4 book ai didi

git - 为单个 git 提交覆盖已配置的用户

转载 作者:IT王子 更新时间:2023-10-29 00:35:05 25 4
gpt4 key购买 nike

我正在尝试在 github.com 上提交一个项目从我的工作笔记本电脑上,它已经为公司的 git 服务器配置好了。有没有一种方法可以使用不同的配置文件或其他命令行开关来提交指定不同的作者凭据?

我试过

--author="My Name <MyNameEmail@email.com>" 

我收到了消息:

 Committer: unknown <WorkEmail@workemail.net>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

但它仍然没有更新我提交到 github.com 项目的用户名。还有什么我可以尝试的,甚至可能吗?

最佳答案

首先,作者不一定与提交者相同。 Git 跟踪两者。

要设置仅用于此存储库的名称,您可以这样做:

git config user.name "Your Name"
git config user.email "Your email"

请注意缺少 --global 选项。这将仅在此存储库中设置配置。

或者,您可以只对单个命令执行此操作,使用 -c 选项:

git -c "user.name=Your Name" -c "user.email=Your email" commit ...

但我认为最好只使用上面的配置选项。

关于git - 为单个 git 提交覆盖已配置的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19840921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com