Skip to main content

Git config for all subfolders from a folder - multiple git config files

· One min read
Hreniuc Cristian-Alexandru

This is a tutorial on how to set a git config for a specific folder where you have work related projects and a folder where you have personal projects.

Create a gitconfig file for your personal projects

Contents of th:

# In ~/data/personal/configs/git/.personal_gitconfig
[user]
name = Hreniuc Cristian-Alexandru
email = email@gmail.com

Add the path to that config in the global git config:

[includeIf "gitdir:~/data/personal/"]
path = ~/data/personal/configs/git/.personal_gitconfig

Make sure you add it at the end of .gitconfig and make sure the last \ from the If exists, otherwise, it won't work.

Source