Managing Git Identities

If you'd like to keep your real-life and modding identities separate, Git and SSH let you manage the identities on a per-folder basis. In other words, you can automate the switch of identities. The final result is that you need to run a single command once for each cloned repository, so it applies the correct identity later on.

This manual is applicable to Linux and Windows. The guide may work on MacOS, but it was not tested.

As a git console for Windows, you can use Git Bash.

Configuring name and email per folder
The manual will use "ChangeMe" as a dev identity. Replace it with your own before applying the commands.

Create a  file and populate with the paths you want to store your different identities in.

When you are in the  folder or any of the children folders, it will use the path you specify to populate the user.name and user.email fields:

The next step is to fill the paths you specified with the desired names and emails:

The result is that git will use the ChangeMe identity for all commit-signing actions in those the folder  and its child folders.

You can check it by doing the following:
 * 1) Clone any repository into your dev-identity folder.
 * 2) Commit anything into the repository.
 * 3) Check the credentials of the commit with.
 * 4) You should see your dev credentials in the shown commit.

Managing multiple SSH keys
When pushing to Git, it will require SSH keys associated with your account.

In our case, we have multiple identities, so if we don't tell SSH to use different keys for different identities, it will send a wrong key and the push will fail.

We need to generate a new SSH key-pair. The following command will create a new public and private key in the  folder:

Next open  and define aliases for when to use which keys:

Now if you push to, the default URL you paste from Github, it will use the public identity, and if you push to  , it will use the dev identity.

The last and recurring step
You need to do this step once for each repository where you want to use your dev identity. Every time you clone or re-clone a repository, you need to do this step.

For each dev repository, run the following command to point to the new remote:

You can check that you set it correctly by
 * 1) Checking the results of  ,
 * 2) Committing locally and checking the credentials,
 * 3) Pushing to remote successfully.

You are now using a unique name, email, and SSH key for your dev identity, and it is automatically applied without any manual switching of credentials.

However, please remember that it works only for the path you set up in gitconfig, so you need to change the rules if you move your dev folder.