我从终端的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”
推荐文章
- 撤消git平分错误
- 使用.gitconfig配置diff工具
- Github:我能看到回购的下载数量吗?
- 如何配置Mac OS X术语,使git有颜色?
- Visual Studio Code: .git文件夹/文件隐藏
- “node_modules”文件夹应该包含在git存储库中吗
- 为什么git-rebase给了我合并冲突,而我所做的只是压缩提交?
- 如何运行一个github-actions步骤,即使前一步失败,同时仍然失败的工作
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购