在配置git时,我运行了这两个命令:

git config --global user.name "My Name"

git config --global user.email "myemail@example.com"

但是,我怀疑我是否打错了。那么,是否有任何命令可以知道git在配置过程中保存的名称和电子邮件?显然,通过查看提交历史,我可以使用git log命令来知道这一点。但是我必须提交,对吧?我可以通过命令行知道吗?


当前回答

设置全局/所有项目

首先获取并确认旧值:

git config --global user.email
git config --global user.name

输出:(如果git新安装,那么输出将显示为空)

yourold@email.com
youroldgoodname

现在设置新的值

git config --global user.email yournew@email.com
git config --global user.name yournewgoodname

用于当前工作空间或项目 只需从以上所有命令/行中删除——global即可

其他回答

如果你想检查或设置用户名和电子邮件,你可以使用下面的 命令

检查用户名

git config user.name

设置用户名

git config user.name "your_name"

检查邮件

git config user.email

设置/更改电子邮件

git config user.email "your@email.com"

列出/查看所有配置

git config --list

查看git配置类型“-”

git config --list

使用实例全局修改用户名

git config --global user.name "your_name"

修改全局邮件类型为“-”

git config --global user.email "your_email"

设置全局/所有项目

首先获取并确认旧值:

git config --global user.email
git config --global user.name

输出:(如果git新安装,那么输出将显示为空)

yourold@email.com
youroldgoodname

现在设置新的值

git config --global user.email yournew@email.com
git config --global user.name yournewgoodname

用于当前工作空间或项目 只需从以上所有命令/行中删除——global即可

列出配置文件中设置的所有变量及其值。

git config --list

如果你是git的新手,那么使用以下命令来设置用户名和电子邮件地址。

设置用户名

git config --global user.name "your Name"

设置用户邮箱

git config --global user.email "your_email@example.com"

检查用户名

git config user.name

检查用户邮箱

git config user.email

要知道已经配置的git(用户名和电子邮件),最简单的方法是输入:

$ git config -l

这将显示先前配置的信息。 为了更新它,您应该使用命令

$ git config --global user.email "example@email.com"
$ git config --global user.name "your_userName"

你也可以查看: [1]: https://git-scm.com/docs/git-config