Features Tips & Tricks Tutorials

Feature Spotlight: VCS integration in PyCharm

Happy Friday everyone,

Today we’ll take a look at some of the basic VCS features in PyCharm that can help manage different version control systems.

You may already know that PyCharm has seamless integration with major version controls like Git, GitHub, Subversion, Mercurial, Perforce (available only in PyCharm Professional Edition), and CVS. Even though all these version controls have different models and command sets, PyCharm makes life a lot easier by advocating a VCS-agnostic approach for managing them wherever possible.

So here we go:

Checking out a project from a VCS

To import a project from a version control system, click the Check out from Version Control button on the Welcome screen, or use the same VCS command from the main menu:


Version Control settings

A project’s version control settings are accessed via Settings → Version Control. 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:


PyCharm can handle multiple VCS repositories assigned to different folders of the project hierarchy, and perform all VCS operations on them in uniform manner.

Changes tool window and changelists

After version control is enabled for a project, you can see and manage your local changes via the Changes tool window. To quickly access the tool window, press Alt + 9 (Cmd-9 on a Mac):


All changes are organized into changelists that can be created, removed, and made active.

Quick list of VCS operations

When you need to perform a VCS operation on a currently selected file, directory, or even on the entire project, bring up the VCS operations quick-list via Alt+Back Quote (Ctrl-V on a Mac):


Show History

The history of changes is available for a set of files or directories via the VCS operations quick-list, or in the main menu VCS →<version control name> → Show History, or in the context menu → Show History:


To see all changes for a specific code snippet, use the Show History for Selection action.


Annotations are available from the quick-list, the main menu or the context menu. They allow you to see who changed a certain line of code and when:


When you click the annotation, you will see the detailed information about the corresponding commit.

Useful shortcuts

  • Commit current changelist Ctrl+K (Cmd-K on a Mac)
  • Update the project Ctrl+T (Cmd-T on a Mac)
  • Mark selected files and folders as added Ctrl+Alt+A (Alt-Cmd-A on a Mac)
  • Mark selected files and folders as changed (checked out) via Ctrl+Alt+E (Alt-Cmd-E on a Mac)
  • Show diff (available in the Changes tool window) via Ctrl+D (Cmd-D on a Mac)
  • Move changes to another change list (available in the Changes tool window) via F6
  • Push commits to remote repositories via Ctrl+Shift+K (Cmd-Shift-K on a Mac)

Commit options

When committing changes, PyCharm lets you 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.


Ignored files

To configure the ignored files, go to Settings → Version Control, or use the corresponding button in the Changes tool window:


The actual list of ignored files can be displayed in the Changes tool window next to the changelists by clicking the corresponding button.


With PyCharm you can easily create, switch, merge, compare and delete branches (available for Git and Mercurial only). To see a list of existing branches or create a new one, use either the Branches from the main or context menu, or the VCS operations quick-list, or the widget on the right-hand side of the status bar:


For multiple repositories, PyCharm performs all VCS operations on all branches simultaneously, so you don’t need to switch between them manually.

Shelves, stashes, and patches

Shelves and Stashes help you when you need to put away some local changes without committing them to repository, then switch to the repository version of the files, and then come back to your changes later. The difference between them is that Shelves are handled by PyCharm itself and are stored in the local file system, while Stashes are kept in a VCS repository.

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. They are helpful 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 Changes tool window. This is the easiest way to find a particular commit, or to just browse through the history:


In this blog post we touched just a tip of the VCS integration iceberg. Go ahead and try this functionality in action! Here’s a tutorial that can walk you through the VCS integration features and provide additional information. And if after that you’re still craving yet more details, please see our online help.

That’s it for today. See you next week!

image description