IntelliJ IDEA 2017.3 Help

Sync with a remote repository

Before you can share the results of your work by pushing your changes to the upstream, you need to synchronize with the remote repository to make sure your local copy of the project is up to date. You can do this in one of the following ways: fetch changes, pull changes, update your project.

Fetch changes

When you fetch changes from the upstream, all new data from commits that were made since you last synced with the remote repository is downloaded into your local copy. This new data is not integrated into your local files, and changes are not applied to your code.

Fetched changes are stored as a remote branch, which gives you a chance to review them before you merge them with your files. Since fetch does not affect your local development environment, this is a safe way to get an update of all changes to a remote repository.

To fetch changes, from the main menu choose VCS | Git | Fetch.

Pull changes

Pulling changes from a remote repository is a convenient shortcut for fetching and subsequently merging changes. When you pull, you not only download new data, but also integrate it into your local working copy of the project.

To pull changes, do the following:

  1. From the main menu, choose VCS | Git | Pull. The Pull Changes dialog opens.
  2. If your project has several Git repositories, select the path to the local repository that you want to update from the Git Root drop-down list.
  3. If you have several remotes configured for your repository, select the URL of the remote that you want to pull data from in the Remote drop-down list.
  4. Select the branches that you want to fetch changes from and merge into the branch that is currently checked out.
  5. From the Strategy drop-down list, select the merge strategy that will be used to resolve conflicts that occur during merge.
  6. Select the following if necessary:
    • No commit: select this option if you do not want IntelliJ IDEA to automatically commit merge results. In this case, you can inspect them and adjust if necessary.
    • No fast forward: select this option to generate a merge commit even if the merge was resolved as a fast-forward (i.e. only the branch pointer was updated).
    • Squash commit: select this option to create a single commit on top of the current branch instead of merging one or more branches. It produces the working tree and index state as if a real merge took place, but it does not actually make a commit or move the HEAD.
    • Add log information: select this option if you want IntelliJ IDEA to populate the log message with one-line descriptions from the actual commits that are being merged in addition to branch names.
  7. Click Pull to fetch and apply changes from the selected remote repository.

Update your project

If you have several project roots, or want to fetch changes from all branches each time you sync with the remote repository, you may find updating your project a more convenient option.

When you perform the update operation, IntelliJ IDEA pulls changes to all project roots and branches, and merges them into your local working copy (equivalent to pull).

To update your project, do the following:

  1. From the main menu, choose VCS | Update Project or press Ctrl+T. The Update Project dialog opens.
  2. Select the update type (this strategy will be applied to all roots that are under Git version control):
    • Merge: select this option to perform merge during the update. This is equivalent to running git fetch and then git merge, or git pull --no-rebase.
    • Rebase: select this option to perform rebase during the update. This is equivalent to running git fetch and then git rebase, or git pull --rebase (all local commits will be put on top of the updated upstream head).
    • Branch Default: select this option if you want to apply different update strategies for different branches. You can specify the default update type for each branch in the branch.<name> section of the .git/config configuration file.
  3. Specify a method that will be used to save your changes while cleaning your working copy before the update so that your uncommitted changes can be restored after the update is completed:
    • Using Stash: select this option to save local changes in a git stash. This is useful if you need to apply patches with stashed changes outside IntelliJ IDEA, as they are generated by Git itself.
    • Using Shelve: select this option to put local changes to a shelf. Shelving is done by IntelliJ IDEA, and patches generated from shelved changes are normally applied inside IntelliJ IDEA.
Last modified: 12 December 2017