If you have multiple accounts on Github (or whatever git repository host you use) then it can be a little confusing knowing which user you are committing as and how to switch to a different user. In this post I'll show you an easy way to switch between users from the command line.
It's All About The Email
Git (well, Github at least) works based on the "user.email" value of the git config object. Although there are some other ones like "name", email is the main one that Github uses to decide what user make a particular commit. Therefore, to specify what user we want to commit our files as we can just set the user.email config value.
Viewing Current Git User
In order to see the current git, enter this:
Changing To a Different Git User
If you want to switch to a new user, just call the same command and pass in a string of the email address. I recommend using the the --global flag, but it's not always necessary.
The posts on this site are written and maintained by Jim Lynch. About Jim...