Skip to content
Manage multiple .gitconfig files
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



recusrive-gitconfig is a Bash tool to support several .gitconfig within the same Linux session.

It can also be use to handle several dynamic Git identities.


Copy the file recursive-gitconfig in your home folder and source it in your .bashrc.

cp ~/
sed -i '1asource ~/\n' ~/.bashrc

How it works alias git command to look for the closest .gitconfig file in parents folders and use this one instead of the default ~/.gitconfig.

An example

Let's say your home directory is something like:

├── .gitconfig
├── personal
│   ├── .gitconfig
│   ├── project-one
│   ├── project-three
│   └── project-two
└── work
	├── client-project-one
	├── client-project-two
	└── .gitconfig

You basicaly have two main folders, personal and work and subfolders for each project.

Your main config file is ~/.gitconfig but you added two specifics files ~/work/.gitconfig and ~/personal/.gitconfig.


	email =
	name = Arnout Pierre

	lol = log --graph --decorate --pretty=oneline --abbrev-commit
	lola = log --graph --decorate --pretty=oneline --abbrev-commit --all


	email =
	name = Arnout Pierre (Company)
	path = /home/arount/.gitconfig


	name = Arount
	path = /home/arount/.gitconfig

From here there are three specific identities possible to have on the same session,

  • Arnout Pierre / is my default identity, the fallback and will be used everywhere except ~/work and ~/personal.
  • Arnout Pierre (Company) / is my professional identity, only used under ~/work/.
  • Arount / is my personal identity, for my personal projects, only used under ~/personal/.

Because both of my specific .gitconfig files include the default ~/.gitconfig I still access my alias from any identity.


If you experience a bug, please check is sourced at the top of your .bashrc.

Otherwise feel free to submit an issue or PR.

You can’t perform that action at this time.