Ever wanted to commit something with a different git user? Maybe your employer provided a user for you? Here are some strategies.

For more detailed information of the commands in this post please visit the git config documentation.

Switch git user for one repository

Suppose you checkout a repository for a different customer where you have a different user. To set the user for this new repo use this:

git config user.email youraddress@othercompany.org
git config user.name "your name"

These values are stored in the .git/config of your repository where they can also be edited directly in the file.

Switch git user for all repositories

If you completely switch from assignment and your user too, use the flag --globalto set it globally for all repositories.

Manually choose user

To clear your repo from the preset user information user the following command. On push you are asked to authenticate yourself with username and password.

git config --local credential.helper ""

Hopefully you can now use the user of choice for every repository. Happy using!