如何从本地机器上删除 git 帐户并添加新帐户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43573790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove git account from local machine and add new account
提问by Ebrahim Khalilullah
I have a github account which is configured in my windows pc. Now I have created a new Github account and want to use the new one.
我有一个在我的 windows pc 中配置的 github 帐户。现在我已经创建了一个新的 Github 帐户并想使用这个新帐户。
How will I remove my old account from my windows pc and add the new github account ?
如何从我的 Windows 电脑中删除我的旧帐户并添加新的 github 帐户?
NOTE:I have edited the gitconfig file and added the new user email and username there. But the public key still contains the old user email !!
注意:我已经编辑了 gitconfig 文件并在那里添加了新用户电子邮件和用户名。但是公钥仍然包含旧用户的电子邮件!!
回答by SHAH MD IMRAN HOSSAIN
For windows machine
用于窗户机
you can manage windows credential for doing this
您可以管理 Windows 凭据来执行此操作
go to search button then write
去搜索按钮然后写
manage windows credential
管理 Windows 凭据
then you will find a button double clickit
然后你会发现一个按钮双击它
then remove your current windows credential
然后删除您当前的 Windows 凭据
after that when you are using git again git authentication will be asked
之后,当您再次使用 git 时,将询问 git 身份验证
then you will enter your new github id
然后你将输入你的新github id
Next you need to edit .gitconfig file
接下来你需要编辑 .gitconfig 文件
file path will be like
文件路径将像
C:\Users\Imu
here imuis my user name it will be different in yours
这里imu是我的用户名,你的会有所不同
Now edit .gitconfigfile using text editor like nodepad++or sublime textwith ur current id information
现在使用文本编辑器编辑.gitconfig文件,如nodepad++或带有当前 id 信息的sublime text
hoping it helps
希望有帮助
回答by Jo Ham
Edit 2:
编辑2:
It seems like you are trying to generate a new SSH key for your new account. If that's the case and you think your public key is specified for your old account, you shouldn't worry acording to this post. The comment at the end of your publc key is JUST a comment. You can generate a new one with a different comment if you want to.
您似乎正在尝试为新帐户生成新的 SSH 密钥。如果是这种情况,并且您认为您的公钥是为您的旧帐户指定的,那么根据这篇文章,您不必担心。公钥末尾的评论只是一个评论。如果需要,您可以使用不同的评论生成新的评论。
Original content :
原文内容:
If you are using Bash, you can use your favorite text editor and open the .gitconfig file yourself and remove the credentials you don't want. It is located (in Bash) at "~/.gitconfig".
如果您使用 Bash,您可以使用您喜欢的文本编辑器并自己打开 .gitconfig 文件并删除您不想要的凭据。它位于(在 Bash 中)“~/.gitconfig”。
e.g.:
例如:
nano ~/.gitconfig
I'm pretty sure there is a command you could do for this, but this is how I would do it.
我很确定您可以为此执行一个命令,但这就是我要做的。
Edit:
编辑:
Here is a command line that could do it :
这是一个可以做到的命令行:
git config {--global|--system|--local} --edit
This command line will do exactly the same as the first command line I mentionned except that this one is working not only on Bash and you don't have to know the location of the file by heart. It will use your default text editor.
这个命令行与我提到的第一个命令行完全一样,只是这个命令行不仅在 Bash 上工作,而且你不必记住文件的位置。它将使用您的默认文本编辑器。
{--global|--system|--local}
Means only one of the three options. Use only one depending on the config file you want to edit. Personaly I would not edit the system one, so just look in your local ones (for the repositories you need to) and in the gloabal one.
意味着只有三个选项之一。根据您要编辑的配置文件,仅使用一个。我个人不会编辑系统一,所以只需查看您本地的(对于您需要的存储库)和全球的。
P.S.: I assume you are using command lines. If you don't, I suggest you to try it.
PS:我假设您正在使用命令行。如果你没有,我建议你尝试一下。
回答by Atul
You can use Credential Manager for adding/deleting/modifying existing Github accounts. Steps:
您可以使用凭据管理器添加/删除/修改现有的 Github 帐户。脚步:
- Go to Start -> Type 'Credential Manager' -> Open Credential Manager
- Below window will be displayed
- 转到开始 -> 键入“凭据管理器”-> 打开凭据管理器
- 将显示以下窗口
- Go to 'Windows Credentials' -> Generic Credentials
- You will see an entry for Github
- 转到“Windows 凭据”-> 通用凭据
- 您将看到 Github 的条目
- Click on the entry -> You will see below options
- 单击条目 -> 您将看到以下选项
- You can edit the entry -> Add new username and password -> Click on Save
- 您可以编辑条目 -> 添加新用户名和密码 -> 点击保存
Hope this helps!
希望这可以帮助!