cwhelms cwhelms - 1 year ago 123
Git Question

Git cli: get user info from username

Is there a way to get the name of the user, given only their username?

Something like this output

git show <username>
(I know this doesn't work)

username: username
name: First Last
email: email@address

I know I can do this with a GitHub api call, but would prefer to keep it within the CLI.

Answer Source

There are no "usernames" in Git.

When creating a commit with Git it uses the configuration values of (the real name) and (email address). Those config values can be overridden on the console by setting and exporting the environment variables GIT_{COMMITTER,AUTHOR}_{NAME,EMAIL}.

Git doesn't know anything about github's users, because github is not part of Git. (It always makes me sad when I get the impression that a lot of people think that).

So you're only left with an API call to github (I guess you could do that from the commandline with a little scripting)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download