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


当前回答

首先,您需要从本地机器更改凭据

如果有通用凭证,请删除

配置新用户和电子邮件(如果你想,你可以全局配置)

git config [--global] user.name "Your Name"
git config [--global] user.email "email@address.com"

现在上传或更新你的回购,它会问你的用户名和密码,以获得访问github

其他回答

对于这个问题有一个简单的解决方案,解决方案是删除你的钥匙串的证书,之前的事情会导致它再次询问用户和密码。

步骤:

打开钥匙串访问

在gitHub.com上搜索证书。 删除gitHub.com证书。 在终端中使用git执行任何操作。这再次询问您的用户名和密码。

对于Windows用户,通过以下方式查找密钥链:

控制面板>>用户帐户>>证书管理器>> Windows 证书>>通用证书

如果你已经创建了一个新的Github帐户,并且你想用你的新帐户而不是以前的帐户推送提交,那么.gitconfig必须更新,否则,你将用已经拥有的Github帐户推送到新帐户。

为了解决这个问题,您必须导航到您的主目录并用编辑器打开.gitconfig。编辑器可以是vim, notepad++,甚至notepad。

打开.gitconfig后,只需用你想要推送的新Github帐户用户名修改“名称”。

在linux (Ubuntu 18.04)中,用户名/密码以明文形式保存在文件~/中。Git-credentials,只需编辑文件以使用您的新用户名/密码。

文件格式非常简单,每行包含一个用户/域的凭据,格式如下:

https://<username>:<password>@github.com
https://<username2>:<password2>@bitbucket.com
...

请更新新用户存储库URL

 git remote set-url origin https://username@bitbucket.org/repository.git

我尝试使用下面的命令,它不工作:

git config user.email "email@example.com"
git config user.name  "user"

OR

git config --global user.email "email@example.com"
git config --global user.name "user"
**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.**