Moto
Moto

Reputation: 111

how to configure ~/.gitconfig file instead of individual repo's .git/config file?

How to configure ~/.gitconfig file instead of individual repo's .git/config file?

## use this config if repository belongs to userA@github
[user]
        name = userA
        email = [email protected]

## use this config if repository belongs to userB@github
[user]
        user: userB
        email: [email protected] 

## use this config if repository belongs to userC@bitbuck
[user]
        user: userC
        email: [email protected]

Upvotes: 1

Views: 347

Answers (1)

VonC
VonC

Reputation: 1329092

The easiest way would be:

  • to have userA, userB and userC local account
  • to clone each of the GitHub repo intheir respective local account
  • to have global setting (~userA/.gitconfig, ~userB/.gitconfig, ~userC/.gitconfig) in place with the right user names and emails.

In that case, there would be no configuration required: any repo clone under ~userA home directory would benefit from the right user.name and user.email.

But if you are trying to that automatically under *one local account, then you need to come up with some script which will create/update the right value in the local config file ~/repo/gitHubCloneRepo/.git/config.

Upvotes: 1

Related Questions