PyCharm: several projects in one window, independent version control

I use PyCharm to work with relatively short targeted scripts running a local version using Git.

Until recently, I did not use version control at all. My preferred method of work was to open multiple files in tabs in one PyCharm project and relate to all independently of each other.

Is there a way to use script-specific version control for multiple projects / files in one PyCharm window? I do not quite understand the PyCharm project paradigm and have not found a way to open several projects in one window in independent versions of version control.

+6
source share
1 answer

After some investigation and help from Fred Reimer on the Jetbrains forum, I believe that the answer to this question is "yes, several projects with independent Git repositories can be managed in one window in PyCharm." Here is a toy example illustrating one possible implementation:

Let's say we have two separate projects in Git in the shared scripts directory:

My_unrelated_scripts/ |—script_1/ |—.git |—script_1.py |—script_2/ |—.git |—script_2.py

  • To get started, open PyCharm, then File | New Project File | New Project and go to script_1 .

  • Assuming we already have some Git code and repository, PyCharm will ask: "Do you want to create a project from existing sources?" - select yes.

  • Repeat step 1 for the script_2 directory, and this time PyCharm will also ask where we want to open the project, in a new window or in the current one. Select "Open in current window" and check the box next to "Add to open projects." Repeat this step for any additional projects.

  • Use the Projects menu on the left to view open projects and, importantly, open any Python files from these projects.

  • Once several projects / files have been opened, we can also check the general dependencies of the project to make sure that we do not unnecessarily complicate the relationship between our scripts. Go to File | Settings | Project: <first_opened_project> | Project Dependencies File | Settings | Project: <first_opened_project> | Project Dependencies File | Settings | Project: <first_opened_project> | Project Dependencies to view each open project and its related dependencies. Uncheck all fields that link independent projects.

  • To avoid PyCharm applying Git actions ( branch , merge , etc.) to all open projects, we can go to File | Settings | Version Control | Git File | Settings | Version Control | Git File | Settings | Version Control | Git and make sure that "Control repositories synchronously" are not checked.

Performing Git actions separately for each project simply requires the use of VCS | Git | Commit File VCS | Git | Commit File VCS | Git | Commit File with a specific file in focus. Alternatively, you can use the dedicated VCS Commit Changes button (Ctrl-K hotkey on Linux / Windows), but in this case we must deselect the files with the changes that we don’t want to include in the current commit (at the top of the " Commit Changes "), because PyCharm will by default include all modified files that are currently open in the window.

+7
source

All Articles