IntelliJ, unable to share Project on GitHub (Permission Denied)

流过昼夜 提交于 2020-04-11 01:37:49

问题


I'm new to Git and GitHub/GitLab. I try to share my project to GitHub but it throws this exception:

Can't finish GitHub sharing process
        Successfully created project 'LiveGame1' on GitHub, but initial push failed:
        git@github.com: Permission denied (publickey).
        Could not read from remote repository.
        Please make sure you have the correct access rights
        and the repository exists.

I'm also able to clone a repository via internet link, but not via "git@github.com:/username/repository_name".

How can I fix this error and am I able to share my project directly to GitLab?


回答1:


I have faced same problem and i generated public key for intelliJ in github account.

Settings -> Developer settings -> Personal access token

Then generate a new token for intelliJ by providing necessary scope and description.and copy the token key.

After that in intelliJ select Login via token access.Login by pasting the key in the form displayed.

Thank you




回答2:


This question is too broad. Needs more details to clarify.

Run git remote show -n origin (Assuming you are on branch origin. -n flag means "do not query remotes", which reduce the operating time for web requests.), you may see the remote URL.

In many common cases, for example on GitHub, Git URLs are in HTTPS protocols

https://github.com/<user>/<repo>.git

or SSH protocols

git@github.com:<user>/<repo>.git

If the field user is not you, or one of your organizations, then you seems trying to contribute to someone's repository. Please fork and create a pull request to do so. You may need to change your local repo's remote url with command

git remote set-url <branch> <newurl>

If user is you, then check if you have input your token correctly.

  • If you are using HTTPS protocol, check the username and password you input. You may need to check Git Credentials.
  • If you are using SSH protocol, make sure you have the corresponding SSH key from your computer to GitHub. You may test the connection with command ssh -T git@github.com.

Update 1: There seems a typo in your question, git@github.com:/username/repository_name. Note the first slash. I am not sure if it troubles.

Update 2: Check your Git credentials save in your IntelliJ IDEA in File -> Settings -> Version Control -> GitHub

Update 3: You are able to share it to GitLab too, just add one remote, for example run command git remote add gitlab <url>.



来源:https://stackoverflow.com/questions/54038611/intellij-unable-to-share-project-on-github-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!