简体   繁体   English

IntelliJ IDEA GitHub集成创建了存储库,但尝试推送时出现“无法授权”错误

[英]IntelliJ IDEA GitHub integration creates the repository, but gets “couldn't authorize” error trying to push

  1. I create a new project in IntelliJ IDEA 我在IntelliJ IDEA中创建了一个新项目

  2. Via the menu, I go to VCS -> Import into Version Control -> Share project on GitHub 通过菜单,我转到VCS - >导入到版本控制 - >在GitHub上共享项目

  3. Enter a new repository name and click Share 输入新存储库名称,然后单击“共享”

  4. It authenticates with GitHub ok 它使用GitHub进行身份验证

  5. When I try to push to GitHub, a login window opens that says "Login to https://github.com/myemail@gmail.com/GitHubTest2.git " 当我尝试推送到GitHub时,会打开一个登录窗口,显示“登录到https://github.com/myemail@gmail.com/GitHubTest2.git

  6. The default login is github.com/my_username. 默认登录名是github.com/my_username。 I try to login with that login and my GitHub.com password and authentication fails. 我尝试使用该登录名登录并且我的GitHub.com密码和身份验证失败。 I also try to login with my GitHub.com login (ie myemail@gmail.com) and my GitHub.com password. 我也尝试使用我的GitHub.com登录(即myemail@gmail.com)和我的GitHub.com密码登录。

  7. After 3 tries, I get the following error message: 3次尝试后,我收到以下错误消息:

Push to GitHub failed Push authorization failure: Couldn't authorize 推送到GitHub失败推送授权失败:无法授权

Why does it authenticate with GitHub with my GitHub.com login/password but not when it tries to push the project to GitHub? 为什么它使用我的GitHub.com登录/密码与GitHub进行身份验证,但是当它试图将项目推送到GitHub时却没有?

The following worked for me: 以下对我有用:

  • Instead of using username and password use a personal access token. 使用个人访问令牌而不是使用用户名和密码。 In GitHub: Go to "Account settings" > "Applications" and generate a "Personal Access Token" 在GitHub中:转到“帐户设置”>“应用程序”并生成“个人访问令牌”

In IntelliJ: 在IntelliJ中:

  • Go to "Settings" > "Version control" > "GitHub" and enter your login and the generated access token. 转到“设置”>“版本控制”>“GitHub”,然后输入您的登录名和生成的访问令牌。 Now pushing to the GitHub repo should work. 现在推送到GitHub仓库应该可行。
  1. See Git push requires username and password . 请参阅Git push需要用户名和密码

  2. Try to use ssh instead of https ( with the generated keypair: https://help.github.com/articles/generating-ssh-keys ). 尝试使用ssh而不是https(使用生成的密钥对: https//help.github.com/articles/generating-ssh-keys )。

This may solve the issue for you, for me it just changed the error message I was seeing in IntelliJ from GitHub to "remote host hung up unexpectedly." 这可能会为您解决问题,对我而言,它只是将我在IntelliJ中看到的错误消息从GitHub更改为“远程主机意外挂起”。

I then tried pushing to GitHub from terminal and it worked. 然后我尝试从终端推送到GitHub,它工作正常。 From terminal, it works regardless of whether I use SSH or https. 从终端,无论我使用SSH还是https,它都可以工作。 I therefore suggest using command line git for pushing code to GitHub instead of the IntelliJ integration. 因此,我建议使用命令行git将代码推送到GitHub而不是IntelliJ集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM