我从终端的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.**

请更新新用户存储库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"

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

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

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

我自己最近也面临着同样的问题。在我的情况下,我有两个github账户:工作和个人。我想把我的启动器代码推到我个人帐户的存储库中,但全局配置有我的工作帐户。我不想每次在工作和个人项目之间切换时都重新配置全局。因此,我使用这些命令为特定的个人项目文件夹设置用户名和电子邮件。

解决方案:

$ git配置用户名

$ git config user.email “Alex@example.com”

$ git配置凭证。用户名“your_account_name_here”