Skip to content

Instantly share code, notes, and snippets.

@deeja
Created February 4, 2021 10:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeja/a4f1e3010ad16647513e9af21762c1ac to your computer and use it in GitHub Desktop.
Save deeja/a4f1e3010ad16647513e9af21762c1ac to your computer and use it in GitHub Desktop.
Conditional Git Configuration on Windows
# Config in MY_WORK_DIRECTORY
[user]
name = "Work user"
email = email@mywork.co.uk
# ROOT CONFIG
# Check out https://blog.jiayu.co/2019/02/conditional-git-configuration/
[user]
name = "Base user"
email = email@example.co.uk
[core]
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor
[includeIf "gitdir:C:/development/MY_WORK_DIRECTORY/"]
path = C:/development/MY_WORK_DIRECTORY/.gitconfig
@michaelsync
Copy link

Unfortunately, it doesn't work for me. "git config user.email" always returns the default user even I am in my work directory.

Windows 11 + git version 2.40.1.windows.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment