我从终端的git中推拉,然后我在github.com上更改了我的用户名。我去推送一些更改,它无法推送,因为它仍然识别我的旧用户名。如何在终端的git上更改/更新我的用户名?
当前回答
**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
...
如果你已经创建了一个新的Github帐户,并且你想用你的新帐户而不是以前的帐户推送提交,那么.gitconfig必须更新,否则,你将用已经拥有的Github帐户推送到新帐户。
为了解决这个问题,您必须导航到您的主目录并用编辑器打开.gitconfig。编辑器可以是vim, notepad++,甚至notepad。
打开.gitconfig后,只需用你想要推送的新Github帐户用户名修改“名称”。
如果你使用包含你的用户名的url克隆了你的repo,那么你也应该改变remote.origin.url属性,否则它会一直询问旧用户名的密码。
例子:
remote.origin.url=https://<old_uname>@<repo_url>
应改为
remote.origin.url=https://<new_uname>@<repo_url>
请更新新用户存储库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"
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添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- 只用GitHub动作在特定分支上运行作业
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 是否有一个链接到GitHub下载文件的最新版本的存储库?