Skip to content

Instantly share code, notes, and snippets.

@swalahamani
Created November 4, 2022 12:13
Show Gist options
  • Save swalahamani/c7e3fc49013d45f711745722f74f1a93 to your computer and use it in GitHub Desktop.
Save swalahamani/c7e3fc49013d45f711745722f74f1a93 to your computer and use it in GitHub Desktop.
Multi Git Account Configuration for different paths:

Multi Git Account Configuration for different paths:

Suppose your Secondary development folder path is:

/Users/swalahamani/DEV/SecondDevHome

Configure your Users/swalahamani/.gitconfig file like the below:

[core]
	editor = nano
[user]
	email = <[email protected]>
	name = <Your Full Name>
	signingkey = <PERSONAL-GPG-KEY-ID>
[commit]
	gpgsign = true
[branch]
	autosetuprebase = always
[init]
	defaultBranch = main
[log]
	date = iso-local
[includeIf "gitdir:~/DEV/SecondDevHome/"]
  path = ~/.gitconfig-second-dev-home

Configure your Configure your Users/swalahamani/.gitconfig-second-dev-home file like below:

[core]
	editor = nano
[user]
	email = <[email protected]>
	name = <Your Full Name>
	signingkey = <SECOND-DEV-HOME-GPG-SIGN-KEY-ID>
[commit]
	gpgsign = true
[branch]
	autosetuprebase = always
[init]
	defaultBranch = main
[log]
	date = iso-local

You can add as many paths and config files as you wish with different different user accounts. Please note that, the other config options except the below mentioned section:

[includeIf "gitdir:~/DEV/SecondDevHome/"]
  path = ~/.gitconfig-second-dev-home

put in the main Users/swalahamani/.gitconfig file can be adjusted according to your needs.

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