The Git integration in IntelliJ IDEA 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 IntelliJ IDEA update it silently.
Before uploading changes from your local Git repository to a remote repository make sure that:
- You have a Git hosting account.
- The target remote Git repository is accessible for your account.
- You have a pair of
ssh keysto access the remote repository.
In this section:
- Pushing changes
- Updating a local branch interactively if push is rejected
- Configuring automatic update if push is rejected
-
On the main menu, choose VCS | Git | Push .
The Git Push dialog box opens listing all commits made in the current branch since the last
push. - Select the commit to push. The right-hand pane shows the changes included in the selected commit. Use the toolbar buttons to examine the commit details.
-
Select which files you want to upload. To select all files, click the Select All toolbar button
or press ⌘A or ⌘A⌘A or ⌘A⌘A or ⌘A^ A, ⌃A or ⌃A^ X, H, ⌃X, H or ⌃X, H.
-
Specify the target remote branch to push the changes to. If you want to upload the current branch to an alternative branch,
rather than its tracked branch, click the branch name to edit it (note that completion is available for branch names).
You can also click the Edit all targets link in the bottom right corner to edit all branch names simultaneously.
- Click the Push button, when ready. IntelliJ IDEA starts the upload.
-
If
pushis rejected due to lack of synchronization, update the local branch in one of the following ways:- Choose the update strategy manually in the Push Rejected dialog box.
- Have the local branch updated automatically.
When push is rejected due to lack of synchronization between the current local branch and its tracked remote branch,
IntelliJ IDEA displays the Push Rejected dialog box, provided that the Auto-update if push ... rejected check box
in the Git page of the
Preferences dialog box is cleared.
-
If your project uses several local Git repositories, specify the ones to be updated:
-
To have all the local repositories updated, no matter whether
pushhas 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.
-
To have all the local repositories updated, no matter whether
-
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 IntelliJ IDEA 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 Preferences dialog box is selected and the applied update method becomes default. To change this setting, clear the Auto-update if push ... rejected check box.
-
To have this dialog box displayed upon every reject of
-
Invoke the update procedure rebase
or merge
by clicking the buttons Rebase or Merge respectively.
Do one of the following:
-
Open the Preferences dialog box, click Git under the Version Control node,
and in the in the Git page, that opens, select the Auto-update if push ... rejected check box.
If you have not invoked any update operation from the Push Rejected dialog box before and you are enabling the check box initially, IntelliJ IDEA will synchronize the local branch silently by means of the merge
operation.
If you have previously invoked an update operation rebase
or merge
from the Push Rejected dialog box and selected the Remember the update method choice... check box,
IntelliJ IDEA will apply your last choice.
Accordingly, to change the "remembered" setting, clear the check box, access the Push Rejected dialog box, select the Auto-update if push ... rejected check box, whereupon invoke another update strategy.
-
During an interactive update in the Push Rejected dialog box,
select the Remember the update method choice and silently update in future check box,
whereupon invoke the required update method
rebaseormergeby pressing the corresponding button. IntelliJ IDEA saves your choice and will apply it to update the conflicting local branch silently until you change the remembered setting.
See Also
Procedures:
- Committing Changes to a Local Git Repository
- Rebasing Branches
- Merging, Deleting, and Comparing Branches
- Version Control with IntelliJ IDEA
Reference:
Concepts:
External Links: