Version Control Basics
One of the nicest things about IntelliJ IDEA is its seamless integration with the major version control systems.
To learn about the supported version controls, refer to the section Supported Version Control Systems.
In this section:
- Checking out a project from version control
- Version control settings
- Version Control tool window and changelists
- VCS operations quick list
- Show history
- Useful shortcuts
- Commit options
- Ignored files
- Shelves, stashes, and patches
Checking out a project from version control
To import a project from version control, click the Check out from Version Control button on the Welcome screen, or use the same command from the node on the main menu.
If a project has Maven or Gradle build files, IntelliJ IDEA will offer to use them for configuration.
Version control settings
To access version control settings of your project, click Version Control node of the Settings dialog. You can associate any of the project folders with a repository root. These associations can be changed or removed at any time, or you can even opt to disable the version control integration entirely.
IntelliJ IDEA can handle multiple VCS repositories assigned to different folders of the project hierarchy and perform all VCS operations on them uniformly.
Refer to the following sections for details:
Version control tool window and changelists
After version control is enabled for a project, you can see and manage your local changes via the topicId2327ersion Control tool window. There are numerous ways to show this tool window, but the quickest is to press Alt+9.
To make working with changes easier, all changes are organized into changelists that can be created, removed, and made active.
Vcs operations quick list
When you need to perform a VCS operation from on a currently selected file, directory, or even on the entire project, use the VCS operations quick list via Alt+Back Quote.
The changes history is available for a set of files or directories via the VCS operations quick list, or in themain menu , or on the context menu under <Version control name> node.
To see all changes for a specific piece of code, use theaction.
Refer to the section Viewing Changes History for a File or Selection for details.
Annotations allow seeing who and when changed this or that line of code. They are available from both the quick list, the main and context menus.
When you click annotation, you will see the detailed information about corresponding commit.
Refer to the section Working with Annotations for details.
- Commit current changelist Ctrl+K
- Update project Ctrl+T
- Mark selected files and folders as added Ctrl+Alt+A
- Mark selected files and folders as changed (checked out) Ctrl+Alt+E
- Show diff (available in the Version Control tool window) Ctrl+D
- Move changes to another change list (available in the Version Control tool window) F6
- Push commits to remote repositories Ctrl+Shift+K
When committing changes, IntelliJ IDEA lets perform a variety of operations: change the file set to commit to, join the changes with the previous commit by using the Amend commit option, reformat the changed code, optimize imports, ensure that there are no inspection warnings, update the copyright information, or even upload the changes to a remote FTP server.
These files are invisible for the version control systems. You can configure the ignored files on the Ignored Files page of the Settings dialog.
With IntelliJ IDEA, you can easily create, switch, merge, compare and delete branches.
To see a list of existing branches or create a new one, use either the VCS operations quick list, or the widget on the right side of the Status bar.from the main VCS or context menu, or the
For multiple repositories, IntelliJ IDEA performs all VCS operations on all branches simultaneously, so you don't need to switch between them manually.
Shelves, stashes, and patches
The Shelves and Stashes (for Git) help you when you need to put away some of local changes without committing them to repository, then switch to repository version of files, and then come back to your changes later.
They differ slightly in that the Shelves are handled by IntelliJ IDEA itself and are stored in local file system, while stashes are kept in a VCS repository.
The Patches allow you to save a set of changes to a file that can be transferred via email or file sharing and then applied to the code. It’s helpful for when you're working remotely without having a constant connection to your VCS repository and still need to contribute.
To see the entire list of commits in a repository, sorted and filtered by branch, user, date, folder, or even a phrase in description, use the Log tab in the Version Control tool window. This is the easiest way to find a particular commit, or to just browse through the history.