如何注销一个 Github 帐户并使用另一个帐户? [英] how to log out of one Github account and use another account?

查看:143
本文介绍了如何注销一个 Github 帐户并使用另一个帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前是用另外一个github账号练习的,现在搭建了自己的github账号.从现在开始,我将主要使用我自己的帐户.我的问题是我的计算机仍然以另一个 github 帐户名登录(即使我在线登录到自己的 Github 帐户).

我无法将任何内容推送到我自己的 github 存储库,因为显然另一个帐户无权这样做.我如何告诉我的计算机切换到我自己的帐户,以便我可以在线推送到我在 Github 中的存储库?

解决方案

如果您使用的是 OSX,请打开终端并运行:

git credential-osxkeychain 擦除主机=github.com协议=https

擦除钥匙串条目.所以下次它会提示你登录.

要查看缓存的当前凭据,请使用命令 git credential-osxkeychain get 然后按两次 Enter.

如果你只按一次回车,你会调用命令,但它会挂起,如果你第二次按回车,你会被一个对话框提示确认访问你的钥匙串,然后信息会在终端返回

<小时>

如果您想防止将来出现此问题,您可以为 osx-keychain 配置 git helper 工具以存储与存储库的整个路径相关联的登录凭据,而不仅仅是默认域.

在终端输入命令

git config --global --edit

这将打开一个配置文件.如果你还没有,你可能想设置你的默认编辑器,以便文件在你喜欢的应用程序中打开.例如,将 Sublime Text 设置为你的默认编辑器: git config --global core.editor "subl-n -w"

打开配置文件后,搜索useHttpPath(如果不存在则定义它).并将其值设置为 true.它应该是这样的:

[凭证]助手 = osxkeychainuseHttpPath = true

这将指示 git(以及 github)用于登录的任何凭据只应与查询的完整存储库路径相关联,而不是与整个域(在 github 的情况下)Github.com 上的所有存储库相关联.. 所以现在你可以登录你的仓库,你男朋友也可以登录他的仓库,你的登录之间不会有冲突.

I was using another github account to practice, and now I set up my own github account. I will be primarily using my own account from now on. My problem is that my computer still is logged in as another github account name (even though I am logged into my own Github account online).

I cannot push anything to my own github repos, because the other account does not have permission to do that, obviously. How do I tell my computer to switch over to my own account so that I can push to my repos in Github online?

解决方案

If your using OSX, open terminal and run this:

git credential-osxkeychain erase
host=github.com
protocol=https

to erase the keychain entry. So next time it will prompt you to login.

To view the current credentials cached use the command git credential-osxkeychain get followed by pressing enter twice.

if you press enter only once you will invoke the command but it will apear to hang, if you press enter a second time you will be prompted by a dialog box to confirm access to your keychain and then the information will be returned in terminal


If you would like to prevent this issue in the future you can configure the git helper tool for osx-keychain to store your login credentials associated with the entire path of the repository rather than just the domain which is the default.

In terminal enter the command

git config --global --edit

This will open a configuration file. If you haven't already, you may want to set your default editor so the file opens in your preferred application.. For example, to set Sublime Text as your default editor: git config --global core.editor "subl -n -w"

With the config file opened, search for useHttpPath (or define it if it doesn't exist). And set it's value to true. It should look like this:

[credential]
  helper = osxkeychain
  useHttpPath = true

This will instruct git (as well as github) that any credentials used to login should only be associated with the full repository path that was queried, not for the entire domain (in the case of github) all repositories on Github.com.. So now you can be logged into your repository, and your boyfriend can be logged into his repository and there will be no conflicts between your logins.

这篇关于如何注销一个 Github 帐户并使用另一个帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆