For most git users, different git configs for different repos are desired. Here comes a way to get it done once and for ever.
$ cd ~ && tree -La 2
.
├── .gitconfig
└── company
└── .gitconfig
For example, for the user profile case:
-
.gitconfig
: git config under user scope[user] name = YourUsername email = [email protected] # Keep these lines at the bottom of the file [includeIf "gitdir:~/company/"] path = ~/company/.gitconfig
-
company/.gitconfig
: git config for specific repos undercompany
directory[user] name = YourUsernameForCompany email = [email protected]
To check if it works:
$ cd ~/company/any_repo && git config user.name
YourUsernameForCompany
$ git config user.email
[email protected]