PhpStorm 2024.1 Help

Sync with a remote Git repository (fetch, pull, update)

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, or update your project.

The Git branches popup indicates whether a branch has incoming commits that have not yet been fetched:

Incoming commits indicator

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.

There are two ways to fetch changes from the upstream:

  • Select Git | Fetch in the main menu.

  • Alternatively, open the Branches popup and click the Fetch icon in the upper right corner.

    the Fetch icon

Watch this video to get a better view on how fetch operation is performed in IDE.

Update branch

Use update if you need to sync a specific branch with its remote tracked branch. This is a convenient shortcut for fetching and subsequently applying changes to the selected branch.

  • In the Branches popup or in the Branches pane of the Version Control tool window, select a branch and choose Update from the context menu.

PhpStorm will pull changes from the remote branch and will rebase or merge them into the local branch depending on which update method is selected in Settings | Version Control | Git.

Pull changes

If you need to get changes into the current branch from another branch instead of its remote tracked branch, use pull. When you pull, you not only download new data, but also integrate it into your local working copy of the project.

  1. In the main menu, go to Git | Pull. The Pull Changes dialog opens:

    The Pull dialog
  2. If you have a multi-repository project, an additional drop-down appears letting you choose the repository.

  3. If you have several remotes defined for your project, select a remote from the list (by default, it is origin).

  4. Select the branch from which you want to pull changes into the branch that is currently checked out. By default, the remote branch tracked by the current local branch is selected. If you specify a different branch, PhpStorm will remember your choice and display this branch by default in the future.

  5. If you need to pull with options, click Modify options and choose from the following:

    • --rebase: after fetching the changes from a remote branch, PhpStorm will rebase local unpushed changes onto the fetched changes.

    • --ff-only: the merge will be resolved only if it is possible to fast-forward.

    • --no-ff: a merge commit will be created in all cases, even if the merge could be resolved as a fast-forward.

    • --squash: a single commit with all pulled changes will be created on top of the current branch.

    • --no-commit: a merge will be performed, but a merge commit will not be created so that you can inspect the result of the merge before committing.

    For more information about pull options, refer to https://git-scm.com/docs/git-pull.

  6. Click Pull.

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, PhpStorm fetches changes from all project roots and branches, and merges the tracked remote branches into your local working copy (equivalent to pull).

  1. In the main menu, go to 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 the incoming changes into the current branch: 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 the current branch on top of the incoming changes: 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).

If you choose not to show the Update Project dialog in the future, and then want to modify the default update strategy later, go to the Version Control | Confirmation page of settings  Ctrl+Alt+S, select Update under Display options dialog when these commands are invoked, and modify the update strategy the next time you perform an update.

When the update operation is completed, the Update Info tab is added to the Git tool window Alt+9. It lists all commits that were made since the last sync with the remote, and lets you review the changes the same way as in the Log tab.

Last modified: 01 July 2024