Git cli:从用户名获取用户信息 [英] Git cli: get user info from username

查看:230
本文介绍了Git cli:从用户名获取用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



类似这样的输出 git show< username> ; (我知道这是行不通的)

 用户名:username 
名称:第一个最后
电子邮件:电子邮件地址

我知道我可以用GitHub api但希望将其保留在CLI中。

解决方案

Git中没有用户名。



使用Git创建提交时,它使用 user.name (真实名称)和 user.email (电子邮件地址)。通过设置和导出环境变量 GIT_ {COMMITTER,AUTHOR} _ {NAME,EMAIL}


可以在控制台上覆盖这些配置值

Git对github的用户一无所知,因为github不是Git的一部分。所以你只剩下一个对github的API调用了(我想你可以在命令行中用一些脚本来做到这一点。)


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.

解决方案

There are no "usernames" in Git.

When creating a commit with Git it uses the configuration values of user.name (the real name) and user.email (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. So you're only left with an API call to github (I guess you could do that from the command line with a little scripting.)

这篇关于Git cli:从用户名获取用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆