As a consultant, it's pretty common to juggle multiple clients throughout our workdayβkinda like being a tech superhero, but without the cape (and the cool gadgets, sadly). With this tip, say goodbye to those endless local setups!
In the global .gitconfig do the following modifications:
[includeIf "gitdir:~/path/to/first-client/projects/"]
path = ~/.gitconfig-first-client
[includeIf "gitdir:~/path/to/second-client/projects/"]
path = ~/.gitconfig-second-client
Important
Pay attention slash(/) in the end of line, this assert that git recognize all sub-folders as mentioned in the documentation:
"If the pattern ends with /, ** will be automatically added. For example, the pattern foo/ becomes foo/**. In other words, it matches "foo" and everything inside, recursively."
Now inside of the defined files ~/.gitconfig-first-client
and ~/.gitconfig-second-client
you can add different configs like:
# ~/.gitconfig-first-client
[user]
name = JosΓ© Lucas
email = [email protected]
# ~/.gitconfig-second-client
[user]
name = Zevolution
email = [email protected]
signingkey = ssh-rsa AAAA...
[gpg]
format = ssh
[commit]
gpgsign = true
Now when you create a new repository, clone, commit or push a repo, inside the specified projects folder that we configure previously, Git will recognize the configurations by folder
This is very useful when we have something like the following structure:
π /
β£ π professional
β β£ π clients
β β β£ π client-01
β β β β£ π projects
β β β β β£ π project-01
β β β β β β£ π controller
β β β β β β£ π model
β β β β β β£ π view
β β β β β β π README.md
β β β β β£ π project-02
β β β β β β£ π controller
β β β β β β£ π model
β β β β β β£ π view
β β β β β β π README.md
β β β£ π client-02
β β β β£ π projects
β β β β β£ π project-01
β β β β β β£ π controller
β β β β β β£ π model
β β β β β β£ π view
β β β β β β π README.md
β β β β β£ π project-01
β β β β β β£ π controller
β β β β β β£ π model
β β β β β β£ π view
β β β β β β π README.md
By this way you don't care about configure scope local in all new projects!