Managing Git Identities

From GT New Horizons
Revision as of 01:21, 15 July 2022 by OrderedSet (talk | contribs) (Write guide)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

If you'd like to keep your real life and modding identities separate, Git and ssh let you manage different identities on a per-folder basis.

Linux

Configuring name/email per folder

(Here I will use OrderedSet as it is my dev identity; replace it with your own when you are doing this.)

Create a ~/.gitconfig file and populate with the paths you want to store your different identities in. When you are in the includeIf folder or any of the children folders, it will use the path you specify to populate the user.name and user.email fields:

Here ~/.gitconfig-public defines my real name account details and ~/.gitconfig-orderedset defines my dev / OrderedSet account details.

Now fill the paths you defined with your name/email:

Now this will use your dev identity for all commit signing in those folders/child folders:

Managing multiple SSH keys

When pushing to Git, you should use SSH keys associated with your account. If you have multiple identities and you wish to use separate SSH keys, here is how I handled it.

First generate a new key like so, replacing orderedset with your details:

ssh-keygen -t ed25519 -C "orderedset86@gmail.com" -f ~/.ssh/orderedset-id_ed25519

This will create a new public and private key under ~/.ssh:

Now open up ~/.ssh/config and define aliases for when to use the key identities:

Now if you push to git@github.com, it will use the public identity, and if you push to git@orderedset, it will use the OrderedSet / dev identity.

Now modify your dev git repos to point to the new remote using "git remote set-url origin git@orderedset:OrderedSet86/gtnh-flow.git" (replacing with your ID alias and git repo URL):

Done! Now you are using a unique name, email, and SSH key for your dev identity.