# Github - Using Multiple Configs I've recently had the charming experience of needing to have multiple github accounts tied to one machine. Because I do not want my private Github account to publish to a separate organisation's and vice versa, I have to setup multiple git configs on the same machine, with multiple ssh keys. In all honesty this isn't too complicated. ## How to do it Update your main `~/.gitconfig` to simply contain the following: ``` conf [includeIf "gitdir:~/repos/org_a"] path = .gitconfig-org_a [includeIf "gitdir:~/repos/org_b"] path = .gitconfig-org_b ``` Notice the we are referencing separate `.gitconfig-org_X` files, create your new gitconfigs in your home directory and load up your configs in them. One thing that is fantastic is that if certain parts of your configs are shared then you can just leave those bits in the root `.gitconfig`. ### Example `.gitconfig` ``` [includeIf "gitdir:~/repos/org_a"] path = .gitconfig-org_a [includeIf "gitdir:~/repos/org_b"] path = .gitconfig-org_b ``` ### Example `.gitconfig-org_a` ``` [user] email = [email protected] name = my-name [core] sshCommand = ssh -i ~/.ssh/id_ed25519 ``` ### Example `.gitconfig-org_b` ``` [user] email = [email protected] name = "Cool Name" [core] editor = vim [init] defaultBranch = master [core] sshCommand = ssh -i ~/.ssh/id_rsa ```