如何在 git 上设置不同于默认作者的默认提交者?

How do I setup a default committer different from my default author on git?

我想要一个不同于我的默认作者的默认提交者,因为我想区分本地环境和测试环境的提交。我该怎么做?

默认情况下,git considers as Author and Committer what's on your user.email and user.name config values - 无法从配置文件中进行设置。

然而,这两个值can be overridden on a per-commit-basis using environment variables。因此,如果您在 shell 设置中设置这些,您应该能够永久设置不同的提交者。

示例(在您的 ~/.bashrc~/.bash_profile):

GIT_COMMITTER_NAME="Deploy server"
GIT_COMMITTER_EMAIL="deploy@server.dev"

Quick note: to set up author user/email use as follows (or write those entries directly in ~/.gitconfig if you know the file format):

$ git config --global user.name "Igor Santos"
$ git config --global user.email "igor.santos@example.com"