Search code examples
gitgithubpycharm

Pycharm, can't connect to a private repository


My friend started a new (private) repository in Github and added me as a contributor.

I've successfully set up GitHub integration in Pycharm:

Screenshot A

However, when I'm trying to clone the repo, I'm getting a "repository not found" error.

Screenshot B

I've checked and I can see and make changes to the repo from the Github site.

Also, when the repo is changed from private to public, I can clone it, but can not push.

If anyone had run into this kind of problem before, I would be interested to know how they have solved it.

Thank you.

P.S:

I have tried to clone without testing.

I have tried to switch to SSH, and using Token or password authentication.

I have tried editing the link in /.git/config under [remote "origin"] to include my username like so: url = https://username@github.com/repoAuthorUsername/repo-name.git instead of the default: url = https://github.com/repoAuthorUsername/repo-name.git


Solution

  • I've managed to get it working with SSH by following this guide from GitHub.

    One needs to create a new SSH key from git bash (on windows) ssh-keygen -t rsa -b 4096 -C "your_email@example.com" where "your_email@example.com" is your GitHub mail.

    Then one needs to add the SSH key to the ssh-agent: eval $(ssh-agent -s) to start the agent. $ ssh-add ~/.ssh/id_rsa to add the key. (where id_rsa) is the key name.

    After that, one needs to add the key to the GitHub account. In git bash clip < ~/.ssh/id_rsa.pub to copy the key to clipboard and On any page in github go to settings-> ssh -> add ssh key and paste the key in.

    When done, the git bash command ssh -T git@github.com should return:

    Hi username! You've successfully authenticated, but GitHub does not provide shell access.

    At this point cloning and pushing should work in pycharm (provided the setting "clone git repositories using ssh" is ticked in the settings menu)

    TL;DR All of the steps I've mentioned are described in greater detail and screenshots in this link https://help.github.com/articles/generating-an-ssh-key/