在配置git时,我运行了这两个命令:
git config --global user.name "My Name"
git config --global user.email "myemail@example.com"
但是,我怀疑我是否打错了。那么,是否有任何命令可以知道git在配置过程中保存的名称和电子邮件?显然,通过查看提交历史,我可以使用git log命令来知道这一点。但是我必须提交,对吧?我可以通过命令行知道吗?
在配置git时,我运行了这两个命令:
git config --global user.name "My Name"
git config --global user.email "myemail@example.com"
但是,我怀疑我是否打错了。那么,是否有任何命令可以知道git在配置过程中保存的名称和电子邮件?显然,通过查看提交历史,我可以使用git log命令来知道这一点。但是我必须提交,对吧?我可以通过命令行知道吗?
当前回答
使用实例全局修改用户名
git config --global user.name "your_name"
修改全局邮件类型为“-”
git config --global user.email "your_email"
本地修改用户名类型为“-”
git config --local user.name "your_name"
本地更改邮件类型为“-”
git config --local user.email "your_email"
其他回答
使用实例全局修改用户名
git config --global user.name "your_name"
修改全局邮件类型为“-”
git config --global user.email "your_email"
本地修改用户名类型为“-”
git config --local user.name "your_name"
本地更改邮件类型为“-”
git config --local user.email "your_email"
命令git config——list将列出设置。在这里你还可以找到user.name和user.email。
在这里加上我的意见。如果你想获取user。name或user。只发送电子邮件,没有详细输出。
在linux下,输入git config——list | grep user.name。
在windows下,输入git config——list | findstr user.name。
这将只给你user.name。
有时上述解决方案无法在macbook上获得用户名和密码。
IDK为什么?这里我得到了另一个解。
$ git credential-osxkeychain get
host=github.com
protocol=https
this will revert username and password
设置全局/所有项目
首先获取并确认旧值:
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即可