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


当前回答

Github

git config --local user.name "another_username" 
git config --local user.email "email@example.com"
git remote set-url origin https://another_username@github.com/repo_url

其他回答

Github

git config --local user.name "another_username" 
git config --local user.email "email@example.com"
git remote set-url origin https://another_username@github.com/repo_url

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

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

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

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

完成了!

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

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

如果有通用凭证,请删除

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

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

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

**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”