Local Git Configuration

Configuring git users and ssh key authentication is a Recurring Configuration Task, and one of the first steps of Setting up a new workspace.

Avoid Global settings

If you work with multiple git users, and need to use different ssh keys, the best option is to not set global configurations at all. This way you will always be warned when you haven't set your local git config, and this avoids the risk of using the wrong user when committing and pushing.

Setting local config

Test config

Run git config user.name to test what the actual settings are

Troubleshooting

Wrong user used on git push

This is often a problem with the configured ssh key not being loaded.

# Open bash with ssh-agent active
exec ssh-agent bash

# Add ssh key to agent
ssh-add ~/.ssh/<key>

SSH key is not being not used

References