Existing PyCharm project, Existing GitHub Repository: How to link the two?

Hello!

I have an “empty” PyCharm project (with venv and specific Python interpreter support). I have a GitHub repository. How do I link the two such that the local (i.e. “empty”) project becomes a clone of the GitHub repository? (main branch for now)

I tried to type in the git commands from project terminal window, but somehow that removed the Python interpreter reference (bewildering?) I need help so that I can perform this same set of operations for many other projects.

If I clone first and then create the project, an error message is issued, and the project is not created because the folder for venv already exists. If I create the project and then use the git add command, the error is that local commit(s) exist, even with merge overrides. I tried to stash the local commits but that didn't help.

Any advice would be sincerely appreciated. Thanks.

Regrds.

 

0

You will first have to “git clone” the project to an existing local directory

with respect to the venv problem make sure when you point to a new project, answer yes to the “use existing sources”;   Also use the option “Use existing virtual environment”

0

Hello Humberto,

Thanks for fielding my request.

When I enter git clone <github url> in my PyCharm project, I get the message that the folder is not empty.

Here are two of the many variations that I have been unsuccessful with:

Test 1:

  1. Create PyCharm project with support for venv and designated Python interpreter. No user files created at this point.
  2. Clone GitHub repository; error message that the folder is not empty

Test 2:

  1. Create PyCharm project with support for venv and designated Python interpreter. No user files created at this point.
  2. Use git commands to initialize project folder
  3. Use git add command to designate remote repository; error message
  4. Tried to resolve error message with merge, stash, etc. since the local branch is essentially empty but still error messages generated

Test 3:

  1. Clone a remote repository
  2. Tried to create Pycharm project (with support for venv and specific interpreter) in cloned local folder but error messages persisted

Still no luck! Anything else that I can try? Thanks.

Regards.

0

The easy way is to :

File -→ Project From Version Control

This assume you have set up the git plugin

Enter the github URL;  

PyCharm then prompts you to create the venv

If you have a requirements.txt it will even load those modules for you

0
Hey @Baqwas,
To create a project from the github repo please do the following:
1. Prepare an empty directory for your project.
2. Open PyCharm, Get from VCS -> Enter git URL or use your VCS account -> Specify directory from the first step -> Clone
3. Once the repo is cloned, create a new Python interpreter for the project (local virtual environment also will require dedicated directory). 
If you encounter any issues, please let us know and take some screenshots of the problem.
0

请先登录再写评论。