Git: How to configure repo-specific user settings

adamlombard

Adam Lombard

Posted on March 25, 2020

Git: How to configure repo-specific user settings

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
Enter fullscreen mode Exit fullscreen mode

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
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.


Was this helpful? Did I save you some time?

๐Ÿซ– Buy Me A Tea! โ˜•๏ธ


๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
adamlombard
Adam Lombard

Posted on March 25, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Git basics
git Git basics

November 10, 2024

From Remote to Local: Git Clone
github From Remote to Local: Git Clone

September 24, 2024

Basic Git and GitHub commands
webdev Basic Git and GitHub commands

July 9, 2024

Commonly Used Git Commands

ยฉ TheLazy.dev

About