igorsantos07
igorsantos07

Reputation: 4686

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

I'd like to have a default Committer that's different from my default Author, as I want to differentiate commits made from my local env and those from testing env. How do I do that?

Upvotes: 3

Views: 2999

Answers (1)

igorsantos07
igorsantos07

Reputation: 4686

By default, git considers as Author and Committer what's on your user.email and user.name config values - and there's no way to set that from config files.

However, both values can be overridden on a per-commit-basis using environment variables. Thus, if you set these in your shell settings you should be able to set a different committer, permanently.

Example (at your ~/.bashrc or ~/.bash_profile):

GIT_COMMITTER_NAME="Deploy server"
GIT_COMMITTER_EMAIL="[email protected]"

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 "[email protected]"

Upvotes: 4

Related Questions