我从终端的git中推拉,然后我在github.com上更改了我的用户名。我去推送一些更改,它无法推送,因为它仍然识别我的旧用户名。如何在终端的git上更改/更新我的用户名?
你可能需要更新远程URL,因为github把你的用户名放在里面。您可以通过键入来查看原始URL
git config --get remote.origin.url
或者只是去Github上的存储库页面,并获得新的URL。然后使用
git remote set-url origin https://{new url with username replaced}
用你的新用户名更新网址。
git config --list
git config [--global] user.name "Full Name"
git config [--global] user.email "email@address.com"
.git/config
当执行步骤2时,如果你看到credential.helper=manager,你需要打开你的计算机(Win或Mac)的凭据管理器并在那里更新凭据
credential.helper=manager
这是它在窗户上的样子 < / p >
故障排除?了解更多
请更新新用户存储库URL
git remote set-url origin https://username@bitbucket.org/repository.git
我尝试使用下面的命令,它不工作:
git config user.email "email@example.com" git config user.name "user"
或
git config --global user.email "email@example.com" git config --global user.name "user"
若要对一个存储库进行本地更改,请从存储库中输入terminal
git config credential.username "new_username"
更改全局使用
git config --global credential.username "new_username"
(编辑解释:如果你不更改user.email和user.name,你将能够推送你的更改,但它们将在git中注册在前一个用户下)
user.email
user.name
push
Password for 'https://<new_username>@github.com':
我建议你只要找到你的.文件夹,然后打开配置文件就可以了。在文件中粘贴您的用户信息:
[user] name = Your-Name email = Your-email
应该就是这个了。
我们有三种方法可以解决这个问题
要设置帐户的默认身份globally,请运行以下命令
globally
git config --global user.email "you@example.com" git config --global user.name "Your Name" git config --global user.password "your password"
若要仅在当前存储库中设置标识,请删除--global并在项目/Repo根目录中运行以下命令
--global
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配置文件中检查这些值
[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文件:
窗口: c /用户/ & lt;用户名或empID >
Mac或Linux:执行此命令进入主目录cd ~
cd ~
或者简单地一个接一个地运行以下命令
git config --global --edit git commit --amend --reset-author
窗口:
Control Panel >> User Account >> Credential Manager >> Windows Credential >> Generic Credential >> look for any github cert/credential and delete it.
则运行任何git命令将提示输入新用户名和
麦克:
command+space >> search for "keychain Access" and click ok >> search for any certificate/file with gitHub >> delete it.
如果你已经创建了一个新的Github帐户,并且你想用你的新帐户而不是以前的帐户推送提交,那么.gitconfig必须更新,否则,你将用已经拥有的Github帐户推送到新帐户。
为了解决这个问题,您必须导航到您的主目录并用编辑器打开.gitconfig。编辑器可以是vim, notepad++,甚至notepad。
打开。gitconfig后,只需修改“;name”;你的新Github帐户用户名,你想用它来推送。
对于这个问题有一个简单的解决方案,解决方案是删除你的钥匙串的证书,之前的事情会导致它再次询问用户和密码。
步骤:
在gitHub.com上搜索证书。
删除gitHub.com证书。
在终端中使用git执行任何操作。这再次询问您的用户名和密码。
对于Windows用户,通过以下方式查找密钥链:
控制面板>>用户帐户>>凭据管理器>> Windows 证书>>通用证书 .
控制面板>>用户帐户>>凭据管理器>> Windows 证书>>通用证书
从你的终端做:
git config credential.username "prefered username"
git config --global user.name "Firstname Lastname"
通常用户名驻留在git配置下
git config --global user.name "first last"
虽然如果你仍然看到上面的不工作,你可以在你的MAC用户目录下编辑.gitconfig并更新
[user] name = gitusername email = xyz@xyz.com
首先,您需要从本地机器更改凭据
git config [--global] user.name "Your Name" git config [--global] user.email "email@address.com"
如果你已经使用包含你的用户名的url克隆了你的repo,那么你也应该改变remote.origin.url属性,否则它会一直询问旧用户名的密码。
remote.origin.url
remote.origin.url=https://<old_uname>@<repo_url>
应改为
remote.origin.url=https://<new_uname>@<repo_url>
**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。
当执行第2步时,如果你看到credential.helper=manager,你需要打开你的计算机(Win或Mac)的凭据管理器并更新那里的凭据
可以在终端中使用此命令更改当前git用户
$ git config --global user.name "Bob" $ git config --global user.email "bob@example.com"
我自己最近也面临着同样的问题。在我的情况下,我有两个github账户:工作和个人。我想把我的启动器代码推到我个人帐户的存储库中,但全局配置有我的工作帐户。我不想每次在工作和个人项目之间切换时都重新配置全局。因此,我使用这些命令为特定的个人项目文件夹设置用户名和电子邮件。
解决方案:
$ git config user.name "Alex"
$ git config user.email "Alex@example.com"
$ git config credential.username "your_account_name_here"
在linux (Ubuntu 18.04)中,用户名/密码保存为明文在文件~/.git-credentials中,只需编辑该文件以使用您的新用户名/密码。
~/.git-credentials
文件格式非常简单,每行包含一个用户/域的凭据,格式如下:
https://<username>:<password>@github.com https://<username2>:<password2>@bitbucket.com ...
打开终端,试一下下面两条线
git配置——global user.name " -首先需要设置用户名
Git配置——全局用户。电子邮件“mahendren@gmail.com" -秒需要设置电子邮件
这就是所有的享受你的编码…