Sometimes you may need to have several local Git repositories within a single project. Such multirooted project can be set up in the following ways:

In this topic:

Asynchronous Branch Control

Asynchronous control is applied to the branches in a multirooted project when all local Git repositories in the project are independent. Commit, push, and other operations to the branches in the repositories are applied independently, just as it is done in projects with one Git repository.

  1. Open the Git Branches popup menu.
  2. In the Git Branches popup menu that opens, choose the branch to apply the required action to. The popup menu shows a list of branches in the current repository and a list of all the repositories in the project.

    The current repository is detected in the following way:

    • If you have explicitly selected a file or a folder in the Project tool window or elsewhere, PyCharm treats the root under which the file is located as current repository.
    • If you used the VCS | Git | Git Branches command on the main menu, PyCharm treats the root of the file currently opened in the editor as current repository.

    git_async_branch_control

    Do one of the following:

    • To update a branch in the current repository, select the branch in the list.
    • To access another repository, select it under the Repositories group, and then select the relevant branch in the subordinate popup menu that opens.
  3. Click the branch and choose the required action from the popup menu that opens.

Synchronous Branch Control

In a multirooted project when several mutually connected repositories, it is often helpful to apply synchronous branch control, which involves the following:

When you invoke the Git Branches popup menu for the first time, PyCharm examines the repositories registered in the project. If they all are on branches with same names, PyCharm displays a popup menu that proposes to control branches synchronously.

Rolling back a successful operation if it fails in some of the repositories

If you checkout a branch on several roots and the operation fails for some of the roots but has already succeeded for the others, the branches diverge. For example, the master branch is checked out in one repository while the feature branch is checked out in the other. To prevent this, PyCharm offers to rollback the successful checkout operation, so the the previous checked out branch is checked out again.

git_sync_branch_control_rollback.png

Besides checkout, PyCharm suggests to rollback merge and other branch operations.

See Also

Procedures:

Reference:

External Links:

Web Resources: