4

我们已经在测试服务器上创建了代码的一个分支,现在多个用户正在通过 SSH 连接到新服务器并使用命令行进行所有提交来工作。但是,当然 Git 不知道是谁进行了更改和提交,因此我们需要在提交期间指定作者。

我认为我们可以通过以下方式实现这一目标:

git commit -a -m 'removed temporary images' --author='deed02392 <foo@bar.net>'

但这给出了:

[test-branch 77b9357] removed temporary image 
    Author: deed02392 <foo@bar.net>
    Committer: root <root@vs123.(none)>
    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

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 1 files changed, 0 insertions(+), 0 deletions(-)  delete mode 100644 derp.PNG

期望每个用户每次都更改配置似乎太过分了。这种行为是因为 Git 的设计目的不是让多个用户使用一个存储库吗?

4

2 回答 2

2

只要所有用户使用不同的系统帐户,运行

 git config --global user.***

每个用户应该解决一次问题,即使所有用户都在同一个 repo 上工作,因为这些设置是用户特定的并保存在$HOME/.gitconfig.

su(当然)如果他们在运行 git 之前使用 root 或其他共享帐户,它将不起作用。

于 2013-07-05T09:25:51.953 回答
2

想法1:看看这个链接,它展示了如何使用环境变量来定义作者姓名等。

Idea2:例如,Github 有一个通用的“git”用户,每个人都使用它来将更改推送到他们的存储库,并且他们可能通过 ssh 密钥来区分用户。您可以朝那个方向尝试一些东西,但我不确定它是否适用于您的设置,因为您直接在服务器上工作。

这些链接是相关的:这个链接这个。这是一个解释gitolite 如何发挥 ssh 魔力的链接

于 2013-07-05T09:43:29.200 回答