DEV Community


Git: How to configure repo-specific user settings

Adam Lombard (he/him)
Novelist & developer.
・1 min read

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

$ git config --global "Susanna Bauer"
$ git config --global
Enter fullscreen mode Exit fullscreen mode

This configures and 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 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 "sueB"
$ git config
Enter fullscreen mode Exit fullscreen mode

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.

Discussion (0)

Forem Open with the Forem app