我从终端的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.**
其他回答
从你的终端做:
git config credential.username "prefered username"
OR
git config --global user.name "Firstname Lastname"
首先,您需要从本地机器更改凭据
如果有通用凭证,请删除
配置新用户和电子邮件(如果你想,你可以全局配置)
git config [--global] user.name "Your Name"
git config [--global] user.email "email@address.com"
现在上传或更新你的回购,它会问你的用户名和密码,以获得访问github
对于这个问题有一个简单的解决方案,解决方案是删除你的钥匙串的证书,之前的事情会导致它再次询问用户和密码。
步骤:
打开钥匙串访问
在gitHub.com上搜索证书。 删除gitHub.com证书。 在终端中使用git执行任何操作。这再次询问您的用户名和密码。
对于Windows用户,通过以下方式查找密钥链:
控制面板>>用户帐户>>证书管理器>> Windows 证书>>通用证书
请更新新用户存储库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"
我们有三种方法可以解决这个问题
方法-1(命令行)
要全局设置帐户的默认标识,请运行以下命令
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global user.password "your password"
若要仅在当前存储库中设置标识,请删除——global并在Project/Repo根目录中运行以下命令
git config user.email "you@example.com"
git config user.name "Your Name"
git config user.password "your password"
例子:
email -> organization email Id
name -> mostly <employee Id> or <FirstName, LastName>
**注意:**您可以在您的GitHub配置文件或Bitbucket配置文件中检查这些值
方法2 (.gitconfig)
在主文件夹中创建一个.gitconfig文件(如果它不存在)。 并将以下行粘贴到.gitconfig中
[user]
name = FirstName, LastName
email = FirstName.LastName@company.com
password = abcdxyz
[http]
sslVerify = false
proxy =
[https]
sslverify = false
proxy = https://corp\\<uname>:<password>@<proxyhost>:<proxy-port>
[push]
default = simple
[credential]
helper = cache --timeout=360000000
[core]
autocrlf = false
注意:如果你不在代理的后面,你可以从上面删除代理行
在主目录下创建。gitconfig文件:
windows: c/users/< username或empID >
Mac和Linux:执行该命令进入主目录cd ~
或者简单地一个接一个地运行以下命令
git config --global --edit
git commit --amend --reset-author
方法-3(弹出git凭据)
窗口:
Control Panel >> User Account >> Credential Manager >> Windows Credential >> Generic Credential
>> look for any github cert/credential and delete it.
然后运行任何git命令将提示输入新用户名和 密码(注意:有时你不会提示密码git拉)。
麦克:
command+space >> search for "keychain Access" and click ok >>
search for any certificate/file with gitHub >> delete it.
然后运行任何git命令将提示输入新用户名和 密码(注意:有时你不会提示密码git拉)。
推荐文章
- 在Markdown Jekyll中使用图像说明
- 如何将git配置存储为存储库的一部分?
- 如何修改GitHub拉请求?
- 如何在Github和本地删除最后n次提交?
- 我如何调试git/git-shell相关的问题?
- 错误:无法使用rebase进行拉取:您有未分阶段的更改
- Git隐藏未缓存:如何把所有未分期的变化?
- 如何将文件附加到GitHub问题?
- 真实的恶魔
- 如何从另一个分支获得更改
- Git:权限被拒绝(publickey)致命-无法从远程存储库读取。克隆Git存储库时
- git reflog和log有什么区别?
- git推挂在Total line之后
- 重命名git子模块
- 如何添加谷歌分析跟踪ID到GitHub页面