One of the nicest things about IntelliJ IDEA is its seamless integration with major version controls like Git, GitHub, Subversion, Mercurial, Perforce, TFS, CVS, Visual SourceSafe and Rational ClearCase.
1. Check out a project from version control
To import a project from version control click the
button on the , or use the same command from the on main menu.
|Check out from Version Control|
If the project has Maven or Gradle build files, IntelliJ IDEA will offer to use them for configuration.
2. Version control settings
Project version control settings are accessed via → . You can associate any of the project folders with a repository root. These associations can be 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.
3. Changes tool window and changelists
After version control is enabled for a project, you can see and manage your local changes via the tool window. To quickly access the tool window use the + (+ for Mac) shortcut.
To make working with changes easier, all changes are organized into changelists that can be created, removed, and made active.
4. 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 quick list via the + ( + for Mac) shortcut.
5. Show history
The changes history is available for a set of files or directories via the quick list, or in the main menu → <Version control name> → , or the context menu <Version control name> → .
To see all changes for a specific piece of code, use the
|Show History for Selection action|
Annotations are available from both the quick list, the main and context menus, and they allow you to see who and when changed this or that line of code.
When you click annotation, you will see the detailed information about corresponding commit.
7. Useful shortcuts
- Commit current changelist + ( + for Mac)
- Update the project + ( + for Mac)
- Mark selected files and folders as added + + ( + + for Mac)
- Mark selected files and folders as changed (checked out) via + + ( + + for Mac)
- Show diff (available in the tool window) via + ( + for Mac)
- Move changes to another change list (available in the tool window) via
- Push commits to remote repositories via + + ( + + for Mac)
8. Commit options
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 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.
9. Ignored files
To configure the ignored files go to → , or use the corresponding button in the tool window.
The actual list of ignored files can be displayed in the tool window next to the changelists by clicking the corresponding button.
With IntelliJ IDEA you can easily create, switch, merge, compare and delete branches (Git and Mercurial only). To see a list of existing branches or create a new one, use either the from the main or context menu, or the quick list, or the widget on the right side of the status bar.
For multiple repositories IntelliJ IDEA performs all VCS operations on all branches simultaneously, so you don't need to switch between them manually.
11. Shelves, stashes, and patches
The and 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 are handled by IntelliJ IDEA itself and are stored in local file system, while stashes are kept in a VCS repository. The 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 tab in the tool window. This is the easiest way to find a particular commit, or to just browse through the history.
This is it for the VCS basics. See the following tutorials for more advanced topics.