Version control
Use the VCS Operations Popup ( Alt+` ) or VCS | VCS Operations Popup to quickly invoke any VCS-related commands.
The list of actions in the popup depends on the currently enabled VCS.
The list of VCS Operations popup commands is configurable — you can add or remove them on the Appearance and Behavior | Menus and Toolbars page of the IDE settings Ctrl+Alt+S .
You can also use the following shortcuts to invoke global version control commands:
PyCharm Version Control and git complete tutorial for beginners
replace "My name" and " [email protected] " with your values which will be associated as git account values.
install git for linux
Adding git to Ubuntu and Linux Mint is really easy just by a single command:
Default installation on Ubuntu 18.04 and Linux Mint 18 is:
PyCharm git operation
All version control operations like:
- commit
- pull
- push
- remote
are located in main menu — VCS
For example checking for remotes — linked projects with git can be found:
- VCS
- Git
- Remotes
You can change, delete or add you remotes from the open dialog.
If you work with Version Control you will want to show tool bar Version control by:
- ALT + 9
- or from menu:
- View
- Tool Windows
- Version Control
PyCharm git commit
In order to commit your changes you need to have remove set up.
- go on view Version Control — ALT + 9
- Local Changes
- Select the Changelist — i.e. Default
- Right click
- commit — CTRL + K
- Select what to be commit
- you can commit everything or select only one / several files
PyCharm git push
You can push using the previous section or to push later by using:
- Menu
- VCS
- Git
- Push — CTRL + SHIFT + K
Pycharm git clone
If you want to clone a repository from github.com you can do it by these steps:
- File
- New
- Project from Version Control
- Git
- URL — enter the remote URL address
- for example (Book Think Python) — https://github.com/AllenDowney/ThinkPython.git
- only if you used it for first time
By default you will clone the full repository and will set up the master branch. If you want to change the branch you can clone the address of the other branch.
Pycharm git checkout
If you want to change the current branch or preview older versions (previous commits) you can do it from
- go on view Version Control — ALT + 9
- Log
- Select Revision
- you will see all revision with user and dates on left
- on the right you will see all changes
Pycharm git pull
If you need to pull changes from other users using git can be done by:
- Menu
- VCS
- Git
- Fetch
This will check the remote repository for any changes. In case you need changes you will see them in the Version Control window — ALT + 9 . You can view the new modifications in tab Log. If you want to pull the changes then you can do it from:
- Menu
- VCS
- Git
- Pull
After successful pull request you will see new tab Update Info. There are all changes divided in three different categories:
- Pull(12 items)
- Updated from server(12 items)
- Updated(3)
- Created(7)
- Deleted(2)
PyCharm Version Control
Version Control window can be shown by ALT + 9 or:
- Menu
- View
- Tools Windows
- Version Control
Local Changes
The first tab is named Local Changes inside you can find all your changes separated in changelists. You can do several operations from this tab:
- commit change — CTRL + K — Saving your changes in a repository. Git add adds a change in the working directory to the staging area.
- revert — CTRL + ALT + Z — This will revert (remove, give up) your local changes and will return the older files versions.
- delete — completely delete the file from this project
- Move to another changelist — you may want to maintain several different changelist. This is useful in case of project specific files like IDE, DB settings etc
- ignore — in case that the file is not added to VCS and the remote repository you can ignore files or folders. Several technical folders need to be ignored in order to avoid problems. You can ignore also test directories or big files.
In this tab you can see all revisions and code changes. You can checkout to another version / branch. Compare with previous versions by selecting a file and pressing CTRL + D . New window will be open with two version of your code.
Console
If you want to know what commands are executed or simply check your daily activities related to git. You can visit tab Console. Inside you will find the actual git commands with all parameters. For example:
Update info
The last tab Update info will be shown after successful pull. Inside you can find information about all pulled changes:
- Updated(3)
- Created(7)
- Deleted(2)
Show git information
How to check the current user name or email:
To list everything in the git file:
[email protected]
[email protected]
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/xxx/xxx.gitSetup proxy and Git
Setup by command
The easiest way too add proxy to your git configuration is by:
- proxyuser — proxy user ( you can check the proxy configuration Windows 10 — Settings/Network & Internet/Proxy or ubuntu — System/Preferences/Network Proxy)
- proxypwd — proxy password
- proxy.server.com — proxy server
- 8080 — proxy port
Disable git proxy by
Setup by file
If the command line is not your favorite way of working, you can just edit .gitconfig
- For Windows — check %userprofile% variable — the root of your profile — open it by: notepad %userprofile%.gitconfig in command prompt.
- For Linux /home/user — you can access it by:
- bash sudo nano
and add this line:
Cannot run program "git.exe": CreateProcess error=2, The system cannot find the file specified
If you get error:
It means that PyCharm Cannot find the git program on your machine or the path which is setup is wrong. In this case you can:
- verify that your machine has working git — run git command in your terminal
with expected result: git version 2.7.4
- check the path in your PyCharm:
- Settings — CTRL + ALT + S
- Version Control
- Git
- Path to Git executable
In case of Ubuntu you will see:
Reference
By using SoftHints — Python, Linux, Pandas , you agree to our Cookie Policy.
PyCharm Integration with GitHub
Setting up Version Control for Collaboration Projects
PyCharm is arguably one of the most popular IDEs used by developers on AI / Machine Learning projects. It is a full-featured IDE well suited for professional Python programming. It is available in 2 editions:
- PyCharm Professional Edition which is a paid software after a 30-day free trial period
- PyCharm Community Edition which is free, and this is the version that I currently have on my system
Good amount of information about these can be found at the below location:
PyCharm: the Python IDE for Professional Developers by JetBrains
Save time while PyCharm takes care of the routine. Focus on the bigger things and embrace the keyboard-centric approach…
However in this discussion our focus is to set up Collaboration projects using PyCharm and GitHub.
As the first step, login into GitHub with your user ID, and create a Repository as shown below. Here we create a new Private Repository.
Now lets set-up a secure encrypted communication between the PyCharm IDE & the GitHub Repository. To ensure that your PyCharm IDE can access your GitHub Repository, you must generate a Personal Access Token from here. The scopes gist, read:org, and repo are the minimum that must be granted to the access token. Any additional scopes can be granted as per requirement.
On clicking Generate Token, a new access token is generated. Copy its GUID. This GUID shall be used when setting-up Version Control in PyCharm. In PyCharm go to File Menu→ Settings → Version Control → GitHub. Select the option of logging into GitHub using Token, and enter the GUID here (using the option of logging-in using Token instead of credentials is also beneficial when collaborating with other developers. In such a case everyone can simply use the same token for login, and the GitHub credentials of one user need not be shared). Also, select the option to Clone Git repositories using SSH.
Now PyCharm is permitted to access your GitHub Repo, but we still need to technically enable the secure encrypted exchange via SSH. Unless this is done, it will not be possible to Clone the Repository or Push code changes to it. Most commonly the error would be similar to: Error: Permission denied (publickey). This means that the server rejected your connection request. Open Git Bash which provides the Git Command line. Verify your connection by typing:
Verify that you have a private key generated and loaded into SSH by typing:
The system should ideally print out a string of numbers and letters. If it does not print anything, you will need to generate a new SSH key & associate it with GitHub.
If you do end up needing to generate a new SSH key, type the below command substituting your GitHub email address:
Now the generated key needs to be added to the SSH agent. Remember, this step is only needed if the earlier check did not return any key already loaded into SSH. Start the ssh-agent and add your SSH private key to it by typing:
The last thing remaining now is to configure your GitHub account to use your new (or existing) SSH key. For this, Copy the SSH key to clipboard:
In your GitHub Account settings, go to SSH & GPG Keys. Here, add the new SSH Key by Paste-ing it from clipboard.
This completes the steps for integration of GitHub Repo with PyCharm. To clone the GitHub Repository created in the first step, open PyCharm → Go to Menu VCS → Get from Version Control → Select GitHub → Select the Repo to clone, and Confirm.. and That’s it ! You are ready to roll ! :).
Enable version control
PyCharm supports version control integration at two levels:
At the IDE level, VCS integration is provided through a set of bundled plugins enabled by default.
At the project level, VCS integration is enabled by associating project folders with one or several version control systems.
Associate a project root with a version control system
PyCharm allows you to quickly enable your project’s integration with a version control system, and associate it with the project root. For instructions on how to associate separate project directories with different version control systems, refer to Associate a directory with a version control system.
Press Alt+` to open the VCS Operations Popup and select Enable Version Control Integration .
Alternatively, from the main menu, select VCS | Enable Version Control Integration .
In the Enable Version Control Integration dialog that opens, select a version control system from the list that you want to associate with your project folder.
After VCS integration is enabled, PyCharm will ask you whether you want to share project settings files via VCS. You can choose Always Add to synchronize project settings with other repository users who work with PyCharm.

Note, that this only applicable to Git and Mercurial.
Associate a directory with a version control system
PyCharm supports a directory-based versioning model, which means that each project directory can be associated with a different version control system.
Press Ctrl+Alt+S to open the IDE settings and select Version Control | Directory Mappings .
The Directory Mappings page shows a list of project directories and version control systems associated with them (if no directories have been added, the list only contains the project root).
Click the Add button on the right.
In the Add VCS Directory Mapping dialog that opens, select the Directory option. Type the path to the directory that you want to associate with a version control system, or click the Browse button and select the directory in the dialog that opens.
From the VCS list, select the version control system that will be used to control the files in this directory. Note that this list only contains the version control systems for which the corresponding plugins are currently enabled.
Click OK to save the mapping and return to the Directory Mappings page.
Manage unregistered directories
For projects with Git or Mercurial integration enabled, PyCharm scans project directories to check if there are Git/Mercurial repositories that are not controlled by the IDE. If such repositories are detected, PyCharm displays a notification.
To add an unregistered root, click the Add roots link in the notification. Alternatively, open the Version Control settings page, select the unregistered root you want to add (they are marked grey) and follow the procedure Associate a directory with a version control system.
If you do not want to be notified about these roots again, click the Ignore link in the notification. Note that if new unregistered repositories are added to the project, PyCharm will notify you about them.
Change VCS associations
Press Ctrl+Alt+S to open the IDE settings and select Version Control | Directory Mappings .
The Directory Mappings page shows a list of project directories and version control systems associated with them (if no directories have been added, the list only contains the project root).
Locate the row that corresponds to the directory which you want to put under another version control system.
Click the VCS column. From the list that appears, select a new version control system.
If you select None , VCS integration for the selected directory will be disabled.
- Updated from server(12 items)