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


当前回答

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

例子:

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

应改为

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

其他回答

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

例子:

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

应改为

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

通常用户名驻留在git配置下

git config --global user.name "first last"

虽然如果你仍然看到上面的不工作,你可以在你的MAC用户目录下编辑.gitconfig并更新

[user]
        name = gitusername
        email = xyz@xyz.com
**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.**

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

解决方案:

$ git配置用户名

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

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

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