git egit - 未授权

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14259265/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:14:17  来源:igfitidea点击:

egit - not authorized

eclipsegitegit

提问by Erel Segal-Halevi

I just connected to GIT from Eclipse Juno using EGit, and successfully cloned a certain remote repository. During the clone I entered my Github username and password, but chose not to save them.

我刚刚使用 EGit 从 Eclipse Juno 连接到 GIT,并成功克隆了某个远程存储库。在克隆过程中,我输入了我的 Github 用户名和密码,但选择不保存它们。

Then I tried to "Fetch from Upstream". I got this error:

然后我尝试“从上游获取”。我收到此错误:

https://github.com/biunlp/nlp-lab.git: not authorized

I had no chance of entering my username and password...

我没有机会输入我的用户名和密码...

This is strange since I connected to this repository in order to clone...

这很奇怪,因为我连接到这个存储库是为了克隆......

回答by VonC

A. To specify credentials individually for each remote

A. 为每个遥控器单独指定凭据

  1. Open Git repositories view,
  2. open "Remotes > origin > <your push url>"
  3. click "Change Credentials..."
  1. 打开 Git 存储库视图,
  2. 打开“ Remotes > origin > <your push url>
  3. 单击“更改凭据...”

push menu

推送菜单

(From User Guide - Resource Context Menu)

(来自用户指南 - 资源上下文菜单

B. To specify credentials per server

B. 为每台服务器指定凭据

If you want to access multiple repositories on the same server without providing the same credentials multiple times, you may use .netrc. With this, eGit will use the configuration you provide.

如果您想访问同一服务器上的多个存储库而不多次提供相同的凭据,您可以使用.netrc。这样,eGit 将使用您提供的配置。

  1. Create a text file called .netrc(_netrcin Windows) in the user home directory.
  2. Add content to the file in this form:
  1. 在用户主目录中创建一个名为.netrc_netrc在 Windows 中)的文本文件。
  2. 以这种形式向文件添加内容:
    machine my.server1.com
    login yourUserName
    password yourPassword

    machine my.server2.com
    login yourUserName
    password yourPassword

The Stash documentation contains more information about .netrc

Stash 文档包含有关 .netrc 的更多信息

Security issueThe problem with using .netrc this way is that the password is visible in plain text. Refer to this answer in Stackoverflowto solve that problem.

安全问题 以这种方式使用 .netrc 的问题是密码以纯文本形式可见。请参阅Stackoverflow 中的此答案以解决该问题。

回答by qingshan

You can try:

你可以试试:

eclipse/myeclipse > menu

window > preferences > general > security >

content > click "delete" > ok

eclipse/myeclipse > 菜单

窗口 > 首选项 > 常规 > 安全 >

内容 > 单击“删除” > 确定

回答by gkubed

If you're using Two Factor Authentication on GitHub, the "not authorized" error can be returned even if you are using the correct username and password. This can be resolved by generating a personal access token.

如果您在 GitHub 上使用双因素身份验证,即使您使用正确的用户名和密码,也会返回“未授权”错误。这可以通过生成个人访问令牌来解决。

After generating the secure access token, we'll use this instead of a password. Make sure not to leave the page before you're done, because once you leave the page, you'll never see it again (thankfully it can be regenerated, but anything using the previously generated token will cease to authenticate).

生成安全访问令牌后,我们将使用它而不是密码。确保在完成之前不要离开该页面,因为一旦离开该页面,您将再也看不到它(幸好它可以重新生成,但任何使用先前生成的令牌的内容都将停止验证)。

This assumes that you've successfully installed EGit and that you've successfully cloned a repository.

这假设您已经成功安装了 EGit 并且您已经成功地克隆了一个存储库。

  1. Go to your GitHub.com settings, and in the left hand pane click Personal access tokens.
  2. Click Generate new token. Select the scopes that you'd like this token to be able to use, and generate it.
  3. Copy the token. It should look something like this: 9731f5cf519e9abb53e6ba9f5134075438944888(don't worry, this is invalid).
  4. Back in Eclipse (Juno, since that's OP's version), click Window > Show View > Other.... Under Git, select Git Repositories.
  5. A new pane appears, from which you can open (repository name) > Remotes > origin.
  6. Right click on a node and choose Change Credentials.... Enter your username for User, and your secure access token for the Password.
  1. 转到您的 GitHub.com 设置,然后在左侧窗格中单击Personal access tokens
  2. 单击Generate new token。选择您希望此令牌能够使用的范围,并生成它。
  3. 复制令牌。它应该看起来像这样:( 9731f5cf519e9abb53e6ba9f5134075438944888别担心,这是无效的)。
  4. 回到 Eclipse(Juno,因为那是 OP 的版本),单击Window > Show View > Other...。在 下Git,选择Git Repositories
  5. 将出现一个新窗格,您可以从中打开(repository name) > Remotes > origin
  6. 右键单击一个节点并选择Change Credentials...。输入您的用户名User,以及您的安全访问令牌Password

回答by Michael Potter

I had a similar problem when I changed my password on the remote repository.

我在远程存储库上更改密码时遇到了类似的问题。

Here is how I fixed it on Eclipse on Mac:

这是我在 Mac 上的 Eclipse 上修复它的方法:

Important Note: These instructions have the side effect of clearing all passwords and other secure information. I was fine with that, but you will want to consider that before you follow these instructions.

重要说明:这些说明具有清除所有密码和其他安全信息的副作用。我对此表示同意,但在遵循这些说明之前,您需要考虑这一点。

  1. Click Eclipse -> Preferences on menu.
  2. Expect a popup window called Preferences.
  3. Expand the "General" tree item.
  4. Double click the "Security" tree item.
  5. Expect the main pane of the popup to change to "See 'Secure Storage' for..."
  6. Click 'Secure Storage'.
  7. Expect the main pane to change to tabbed window.
  8. Click the "Contents" tab.
  9. Click "Delete".
  10. Accept a warning that all your secure information is deleted.
  11. Click "Cancel" or "Apply" to exit the popup window.
  12. Click the 'Git Pull' icon and expect to be prompted for username and password.
  1. 单击菜单上的 Eclipse -> 首选项。
  2. 期待一个名为 Preferences 的弹出窗口。
  3. 展开“常规”树项。
  4. 双击“安全”树项。
  5. 预计弹出窗口的主窗格将更改为“请参阅‘安全存储’以...”
  6. 单击“安全存储”。
  7. 期望主窗格更改为选项卡式窗口。
  8. 单击“内容”选项卡。
  9. 点击“删除”。
  10. 接受警告,即您的所有安全信息都将被删除。
  11. 单击“取消”或“应用”退出弹出窗口。
  12. 单击“Git Pull”图标,系统会提示您输入用户名和密码。