我从终端的git中推拉,然后我在github.com上更改了我的用户名。我去推送一些更改,它无法推送,因为它仍然识别我的旧用户名。如何在终端的git上更改/更新我的用户名?


当前回答

在终端中,导航到要在其中进行更改的回购。 执行git配置——list检查当前用户名和电子邮件在你的本地回购。 根据需要更改用户名和电子邮件。使其成为全局更改或特定于本地回购:

git配置[——global] user.name“全称”

Git配置[——global]用户。电子邮件“email@address.com”

每个回购基础上,你也可以手动编辑.git/config。

完成了!

执行第2步时,如果您看到凭据。你需要打开你的计算机(Win或Mac)的凭据管理器并在那里更新凭据

其他回答

**Check by executing this** 
git config --list
**Change user email** 
git config --global user.email "email@example.com"
**Change user name**
git config --global user.name "user"
**Change user credential name** 
git config --global credential.username "new_username"
**After this a window popup asking password.
Enter password and proceed.**

在终端中,导航到要在其中进行更改的回购。 执行git配置——list检查当前用户名和电子邮件在你的本地回购。 根据需要更改用户名和电子邮件。使其成为全局更改或特定于本地回购: git配置[——global] user.name“全称” Git配置[——global]用户。电子邮件“email@address.com” 每个回购基础上,你也可以手动编辑.git/config。 完成了!

执行第2步时,如果您看到凭据。你需要打开你的计算机(Win或Mac)的凭据管理器并在那里更新凭据

这是它在窗户上的样子

故障排除?了解更多

我建议你只需转到你的。git文件夹,然后打开配置文件。在文件中粘贴您的用户信息:

[user]
    name = Your-Name
    email = Your-email

应该就是这个了。

从你的终端做:

git config credential.username "prefered username"

OR

git config --global user.name "Firstname Lastname"

如果你使用包含你的用户名的url克隆了你的repo,那么你也应该改变remote.origin.url属性,否则它会一直询问旧用户名的密码。

例子:

remote.origin.url=https://<old_uname>@<repo_url>

应改为

remote.origin.url=https://<new_uname>@<repo_url>