在 Git 和 Subversion 中,如何在终端找到当前用户?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1409002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:02:12  来源:igfitidea点击:

In Git and Subversion, how do I find out the current user at the terminal?

svngit

提问by Thierry Lam

In Perforce, I can check who I am by running p4 info, here's the p4 doc. What's the equivalent for Git and Subversion at the terminal?

在 Perforce 中,我可以通过运行来检查我是谁p4 info,这是p4 文档。终端上 Git 和 Subversion 的等价物是什么?

回答by Dipstick

Presumably you are after the git user name that will be attached to any commits:

想必您是在将附加到任何提交的 git 用户名之后:

$ git config user.name
Wilbert Wilbert

$ git config --list
user.name=Wilbert Wilbert
[email protected]
color.status=auto
color.branch=auto
...

Keys might appear more than once because Git reads from several files (/etc/gitconfig and ~/.gitconfig, for example). Git uses the last value for each key it sees.

键可能会出现多次,因为 Git 从多个文件(例如 /etc/gitconfig 和 ~/.gitconfig)中读取。Git 使用它看到的每个键的最后一个值。

回答by abe312

For name:

对于名称:

git config user.name

For email:

对于电子邮件:

git config user.email

General:

一般的:

git config --list
(this shows all available information)

回答by bahrep

There are several ways to find out stored logon credentials that will be used when you access remote Subversion server:

有几种方法可以找出访问远程 Subversion 服务器时将使用的存储登录凭据:

  • Run svn authto view credentials and certificates cached in SVN credential store (%APPDATA%\Subversion\auth).
  • Run cmdkeyto view the credentials stored in Windows Credential Manager.
  • If your SVN server is integrated with Active Directory and supports Integrated Windows Authentication, your Windows logon credentials are used for authentication, but they are not cached. You can run whoamito find out your user account name .
  • 运行svn auth以查看缓存在 SVN 凭据存储 ( %APPDATA%\Subversion\auth) 中的凭据和证书。
  • 运行cmdkey以查看存储在 Windows 凭据管理器中的凭据。
  • 如果您的 SVN 服务器与 Active Directory 集成并支持集成 Windows 身份验证,则您的 Windows 登录凭据将用于身份验证,但不会缓存它们。您可以运行whoami以找出您的用户帐户名。

Note that there is no such thing as "current user" in SVN. In most cases, "current user" refers to user credentials cached on client that will be automatically presented to server on every access to the server.

请注意,SVN 中没有“当前用户”这样的东西。在大多数情况下,“当前用户”是指缓存在客户端上的用户凭据,在每次访问服务器时都会自动呈现给服务器。