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


当前回答

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

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

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

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

完成了!

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

其他回答

在终端中,导航到要在其中进行更改的回购。 执行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.**

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

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

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

你可能需要更新远程URL,因为github把你的用户名放在里面。您可以通过键入来查看原始URL

git config --get remote.origin.url

或者只是去Github上的存储库页面,并获得新的URL。然后使用

git remote set-url origin https://{new url with username replaced}

用你的新用户名更新网址。

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

如果有通用凭证,请删除

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

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

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