loading...

Git: How to configure repo-specific user settings

adamlombard profile image Adam Lombard ・1 min read

Many Git tutorials instruct us to do something like the following when first setting up Git:

$ git config --global user.name "Susanna Bauer"
$ git config --global user.email susanna@example.com

This configures user.name and user.email settings globally, for every repo on our machine.

But, say we use the same computer to work in multiple Git repositories across two or more accounts. Perhaps we have separate professional and hobby GitLab accounts, for instance. How do we override the global settings, and configure user.name and user.eamil on a per-repo basis?

We can cd into our repo, and re-run the same commands without the --global flags:

$ git config user.name "sueB"
$ git config user.email sb@example.com

The global settings remain unchanged, but this repository will use the new, local settings. You can see the local configuration at <repo>/.git/config.


Learn more about the artwork of Susanna Bauer.

Posted on by:

Discussion

pic
Editor guide