The Git integration in PyCharm supports uploading changes from the current branch to its tracked branch or to any other remote branch. If the upload (push) is rejected due to lack of synchronization between your local repository and the remote storage, you can either interactively choose the strategy to update the local branch or have PyCharm update it silently.

Before uploading changes from your local Git repository to a remote repository make sure that:

In this section:

  1. On the main menu, choose VCS | Git | Push . The Git Push dialog box opens.
  2. The left-hand pane shows all the commits made in the current branch since the last push. To get the list up-to-date, click the Refresh commit list button refresh.png.
  3. Select the commit to push. The right-hand pane Commit Details shows the changes included in the selected commit. Use the toolbar buttons to examine the commit details.
  4. Appoint the changes to be uploaded by selecting the relevant files in the tree or list. To have all the files selected, click the Select All toolbar button svnSelectAll.png or press Ctrl+A.
  5. Specify the target remote branch to push the changes to.
    • To have the current branch uploaded to its tracked branch, clear the Push current branch to alternative branch check box.
    • To have the current branch uploaded to another existing remote branch, select the Push current branch to alternative branch check box and choose the required branch from the Target Branch drop-down list.

      If your project uses several Git repositories, the list shows only the branches that are common for all repositories. For example, if your project uses repo_one and repo_two, where repo_one has two branches origin and github while repo_two has only origin, then only origin will be available from the drop-down list, so there is no way to push to github from PyCharm.

    • To publish a local branch, that is, to push it to a new branch, select the Push current branch to alternative branch check box and type the name of the new branch in the text box. PyCharm will automatically set up tracking (git push -u origin newbranch).
  6. Click the Push button, when ready. PyCharm starts the upload.
  7. If push is rejected due to lack of synchronization, update the local branch in one of the following ways:

When push is rejected due to lack of synchronization between the current local branch and its tracked remote branch, PyCharm displays the Push Rejected dialog box, provided that the Auto-update if push ... rejected check box in the Git page of the Settings dialog box is cleared.

  1. If your project uses several local Git repositories, specify the ones to be updated:
    • To have all the local repositories updated, no matter whether push has been rejected for all of them or not, select the Update non rejected repositories as well check box.
    • To have only affected repositories updated, clear the Update non rejected repositories as well check box.
  2. In the Push Rejected dialog box, specify the way to update local repositories in the future:
    • To have this dialog box displayed upon every reject of push, clear the Remember the update method choice and silently update in future check box.
    • To have PyCharm apply the update procedure invoked from this dialog box silently, select the Remember the update method choice and silently update in future check box.

      After you leave the dialog box, the Auto-update if push ... rejected check box in the Git page of the Settings dialog box is selected and the applied update method becomes default. To change this setting, clear the Auto-update if push ... rejected check box.

  3. Invoke the update procedure rebase or merge by clicking the buttons Rebase or Merge respectively.

See Also

Concepts:

Procedures:

Reference:

External Links:

Web Resources: