JavaRush /Java Blog /Random EN /IntelliJ IDEA User Guide. Fundamentals of working with ve...
theGrass
Level 24
Саратов

IntelliJ IDEA User Guide. Fundamentals of working with version control systems

Published in the Random EN group

Fundamentals of working with version control systems

One of the nicest things about IntelliJ IDEA is the great integration with major version control systems like Git, GitHub, Subversion, Mercurial, Perforce, TFS, CVS, Visual SourceSafe, and Rational ClearCase. IntelliJ IDEA User Guide.  Basics of working with version control systems - 1
  1. Get your project out of source control

    To import your project from version control, click the Check out from Version Control button on the Welcome screen (IDEA welcome window), or in the VCS (Version Control System) menu on the main menu bar.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 2

    If your project has build configuration files for Maven or Gradle , IntelliJ IDEA will prompt you to use them for configuration.

  2. Version control system settings

    The version control settings for your project are available in Settings → Version Control . You can choose any of your project's directories as the root for the version control system you use, and change this choice at any time. You can also turn off version control at any time.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 3

    Also, you can store different directories of your project in different version control systems, IntelliJ IDEA allows you to carry out all operations on them in the same way.

  3. Changes tool window and change lists

    Once you have enabled version control on your project, you can see and manage local changes using the Changes tool window . To quickly open it, press Alt + 9 (Cmd + 9 for Mac) .

    To make it easier to manage changes, they are all organized into change lists that you can create, delete, and make active.

    IntelliJ IDEA User Guide.  Basics of working with version control systems - 4
  4. Pop-up menu of version control operations

    If you need to run some version control system operation on a selected file, directory, or even on the entire project, use the VCS operations pop-up menu by pressing Alt + Back Quote (single left quote, character ') ( Ctrl + V for Mac ).

    IntelliJ IDEA User Guide.  Basics of working with version control systems - 5
  5. Display history of changes

    The change history for files or directories in your project is available from the VCS operations menu , or from the main VCS menu bar → <VCS name> → Show History , or from the context menu <VCS name> → Show History .

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 6

    To see the changes for a particular piece of code, use the Show History for Selection item .

  6. Annotations

    Annotations are available both from the pop-up menu and from the main and context menus. They allow you to see who and when changed each particular line of code.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 7

    By calling the annotation panel, you will see detailed information about the corresponding commit.

  7. Useful keyboard shortcuts

    • Add current changelog to source control Ctrl + K (Cmd + K for Mac)
    • Update Project Ctrl + T (Cmd + T for Mac)
    • Add selected files and directories to source control Ctrl + Alt + A (Alt + Cmd + A for Mac)
    • Mark selected files and folders as modified (updated) Ctrl + Alt + E (Alt + Cmd + E for Mac)
    • View Changes (available in the Changes tool window ) Ctrl + D (Cmd + D for Mac)
    • Move changes to another change list (available in the Changes tool window ) F6
    • Commit your local changes to remote source control Ctrl + Shift + K (Cmd + Shift + K on Mac)
  8. Options for saving changes

    When you check in your changes to source control, IntelliJ IDEA allows you to do all sorts of things: change the list of changes you're adding them to, merge changes with those already added using Amend commit , reformat changed code, optimize imports, make sure code inspection doesn't issues no warnings, update copyright information, or even upload your changes to a remote ftp server.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 8
  9. Ignored files

    You can configure the list of ignored files in the Settings → Version Control menu , or using the corresponding button in the Changes tool window .

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 9

    The current list of ignored files can be seen in the Changes tool window next to the lists of changes by clicking the corresponding button.

  10. branches

    With IntelliJ IDEA, you can easily create, switch, merge, compare, and delete code branches. (only in Git and Mercurial ). To list existing branches or create a new one, use either Branches from the main or context menu, or the VCS operations pop-up menu , or the control on the right side of the status bar.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 10

    For different version control systems, IntelliJ IDEA does all the operations at the same time, so you don't have to switch between them.

  11. Shelves, stashes, and patches

    The Shelves and Stashes menu helps you hide some local changes without adding them to source control. You need this in order to switch to the version of the files that is stored in the version control system and then be able to revert back to your local changes. They differ in that Shelves are maintained by IntelliJ IDEA itself and are stored locally with you, while Stashes are stored in the version control system. Patchesallows you to save a set of changes as a file, which can be emailed or uploaded to a public disk and then applied to the code. This is useful if you're working remotely without a permanent connection to source control, but still need to push your changes to other project members.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 11
  12. Log

    To view a complete list of changes added to source control, sorted and filtered by code branch, username, date, folder, or even description phrase, open the Log tab in the Changes tool window . This is the easiest way to find the changeset you need, or to explore the history of changes.

    IntelliJ IDEA User Guide.  Fundamentals of working with version control systems - 12
Original article
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION