Background
I use multiple Github accounts on one computer.
To make sure that the name and email addresses (which I will call User Identity from here) associated with a commit match up to the name on the respective github account, I make use of .gitconfig files as described in the linked answer. Specifically, I use the IncludeIf
keyword to designate that a directory should use a specific User Identity.
For example, if a repo is in ~/work/
, it will use my "work" User Identity. But a repo in ~/personal/
will use my "personal" User Identity. From the standpoint of someone reading commits from these two repositories, commits would look like they have two different authors.
This system works to keep my identities separate without introducing a lot of complexity in everyday work. But mistakes can happen. I would like to be able to see what User Identity I am using within a particular repo before I issue a commit. That way if I see the wrong identity, I can see where the error in my setup is before I commit changes under the wrong identity.
This would normally be available via the git
executable with a command like git config user.name
or git config user.email
as described by this answer. I am looking for a way to have emacs obtain and show me this information automatically/consistently. Magit seems to have a lot of functionality for git
, so I tagged this question as such.
Question
Is it possible to see what User Identity (Either/both of the User Name and Email) I am using within a repository using Magit? Other non-Magit solutions would be acceptable as long as they are accessible via emacs.
Is it possible to have this information available prominently (such as in the mode line or magit status
buffer)?
Note: I manage the multiple github accounts by using multiple SSH keys with separate ssh configs pointing to the same HostName but with different ssh keys. The ssh key used is controlled by which alias I provide as the host within git clone
or any other repo-controlling command. This may not be fully relevant to my question, but I will provide it just in case.
git in emacs
per your comment about Magit's scope. To clarify: The SSH key is not necessarily tied to User Identity -- I have been able to commit using an SSH key while using a git config for a different account. You would normally be able to access User Identity with git withgit config user.name/user.email
within a repo. I would accept an answer that did not use Magit.