Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (27 sloc) 1.1 KB
title category date
Simple GIT identities (overrides in general) management

I need to be committing intro different repositories under different user identities. To Open Source ones with my private email, while using work email for work-related commits/repos.

Typically, you would use repo-specific identities. For example (my work repo):

git config "Antonin Kral"
git config

Now, that is error-prone and painful. I have discovered a neat feature of git (since 2.13) which allows for conditional inclusion of configuration files. Let's assume the following configuration files:

# ~/.gitconfig

	email =
	name = Antonin Kral

[includeIf "gitdir:~/Sources/dtone/"]
  path = .gitconfig_dtone
# ~/.gitconfig_dtone

   name = Antonin Kral
   email =

And that's it. Every time I work with repo, which is cloned under ~/Sources/dtone, my identity will be automatically changed to work one. This is not limited to identities; you can override anything you want.

You can’t perform that action at this time.