Clone repository
PyCharm allows you to clone (or check out , depending on version control system you use) an existing repository and create a new project based on the data you have downloaded.
You can clone a remote Git, Mercurial, or Subversion repository from the Welcome screen that opens right after launching PyCharm or from the main menu.
If you want to work with Perforce projects, refer to the Perforce guide.
Clone a repository from the Welcome Screen
You can clone a remote Git, Mercurial, or Subversion repository from the Welcome screen that opens right after launching PyCharm.
Clone a remote repository:
Click Get from VCS in the upper right corner.
In the Get from Version Control dialog that opens, select Git from the list.
Specify the URL of the remote repository that you want to clone.
In the Directory field, enter the path to the folder where your local repository will be created.
Click Get from VCS in the upper right corner.
In the Get from Version Control dialog that opens, select Mercurial from the list.
Specify the URL of the remote repository that you want to clone.
In the Directory field, enter the path to the folder where your local repository will be created.
Click Get from VCS in the upper right corner.
In the Get from Version Control dialog, click Add Repository Location and specify the repository URL.
Click Check Out .
In the dialog that opens, specify the destination directory where the local copy of the repository files will be created, and click OK .
If you are checking out sources for an existing project, the destination folder should be below the project content root .
In the SVN Checkout Options dialog, specify the following settings:
Revision to be checked out (HEAD or a selected revision).
Whether you need to check out the nested directories.
Whether you need to include the external locations.

The cloning process starts. In the list of projects, you can see the repository that you are currently cloning with the progress bar of the cloning process. Note that you can clone several repositories at the same time.
When the cloning process finishes, PyCharm opens the project.
Stop the cloning process
Click on the right side of the cloning progress bar.
In the Stop Cloning dialog that opens, choose Stop to stop the cloning process. If you changed you mind, choose Cancel to continue the cloning process.
Clone failed

If there is an error during the cloning process, a notification in the bottom-right corner will warn you about it.
Clone a repository from the main menu
From the main menu, choose Git | Clone .
In the Version control drop-down, select Git .
Specify the URL of the remote repository that you want to clone.
In the Directory field, enter the path to the folder where your local repository will be created.
From the main menu, choose VCS | Get from Version Control .
In the Get from Version Control dialog that opens, select Mercurial from the list.
Specify the URL of the remote repository that you want to clone.
In the Directory field, enter the path to the folder where your local repository will be created.
From the main menu, choose VCS | Get from Version Control .
In the Get from Version Control dialog, click Add Repository Location and specify the repository URL.
Click Check Out .
In the dialog that opens, specify the destination directory where the local copy of the repository files will be created, and click OK .
If you are checking out sources for an existing project, the destination folder should be below the project content root .
Set up a Git repository
When you clone an existing Git repository, or put an existing project under Git version control, PyCharm automatically detects if Git is installed on your computer. If the IDE can’t locate a Git executable, it suggests downloading it.
PyCharm supports Git from the Windows Subsystem for Linux 2 (WSL2), which is available in Windows 10 version 2004.
If Git is not installed on Windows, PyCharm searches for Git in WSL and uses it from there. Also, PyCharm automatically switches to Git from WSL for projects that are opened when you use the \\wsl$ path.
If you need to manually configure PyCharm to use Git from WSL, go to the Version Control | Git page of the IDE settings Ctrl+Alt+S , click the Browse icon in the Path to Git executable field and select Git from WSL via the \wsl$ path, for example, \\wsl$\debian\usr\bin\git .
Check out a project from a remote host (clone)
PyCharm allows you to check out (in Git terms clone ) an existing repository and create a new project based on the data you’ve downloaded.
From the main menu, select Git | Clone , or, if no project is currently opened, click Get from VCS on the Welcome screen.
In the Get from Version Control dialog, specify the URL of the remote repository you want to clone, or select one of the VCS hosting services on the left.
If you are already logged in to the selected hosting service, completion will suggest the list of available repositories that you can clone.
Click Clone . If you want to create a project based on the sources you have cloned, click Yes in the confirmation dialog. Git root mapping will be automatically set to the project root directory.
If your project contains submodules, they will also be cloned and automatically registered as project roots.
Put an existing project under Git version control
You can create a local Git repository based on the existing project sources.
Associate the entire project with a single Git repository
Open the project that you want to put under Git.
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 .
Choose Git as the version control system and click OK .
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.

Associate different directories within the project with different Git repositories
Open the project that you want to put under Git.
From the main menu, choose VCS | Create Git Repository .
In the dialog that opens, specify the directory where a new Git repository will be created.
Git does not support external paths, so if you choose a directory that is outside your project root, make sure that the folder where the repository is going to be created also contains the project root.
If you are creating multiple Git repositories inside the project structure, repeat the previous steps for each directory.
After you have initialized a Git repository for your project, you need to add project files to the repository.
Add files to the local repository
In the Commit tool window Alt+0 , expand the Unversioned Files node.
Select the files you want to add to Git or the entire changelist and press Ctrl+Alt+A or choose Add to VCS from the context menu.
You can also add files to your local Git repository from the Project tool window: select the files you want to add, and press Ctrl+Alt+A or choose Git | Add from the context menu.
When Git integration is enabled in your project, PyCharm suggests adding each newly created file under Git, even if it was added from outside PyCharm. You can change this behavior in the Version Control | Confirmation page of the IDE settings Ctrl+Alt+S . If you want certain files to always remain unversioned, you can ignore them.
If you attempt to add a file that’s on the .gitignore list, PyCharm will suggest force adding it. Clicking Cancel in the confirmation dialog only cancels force adding ignored files — all other files will be added to the Git repository.
Exclude files from version control (ignore)
Sometimes you may need to leave certain files unversioned. These can be VCS administration files, artifacts of utilities, backup copies, and so on. You can ignore files through PyCharm, and the IDE will not suggest adding them to Git and will highlight them as ignored.
You can only ignore unversioned files, that is files that you see in the Unversioned Files changelist. If a file is added to Git but not committed, you can right-click it in the Local Changes view and choose Rollback .
Git lets you list ignored file patterns in two kinds of configuration files:
Patterns listed in this file only apply to the local copy of the repository.
This file is created automatically when you initialize or check out a Git repository.
One or more .gitignore files in the VCS root directory and its subdirectories.
These files are checked into the repository so that the ignore patterns in them are available to the entire team. Therefore, it is a most common place to store the ignored file patterns.
If there is no .gitignore file in the VCS root directory, you can right-click anywhere in the Project tool window, choose New | File and type .gitignore in the New File dialog.
To create a .gitignore file in Windows Explorer, create a file named .gitignore. and Windows will rename it automatically to .gitignore .
Add files to .gitignore or .git/info/exclude
Decide what kind of Git configuration file you are going to use to ignore files. If in doubt, use .gitignore .
Locate the unversioned file or folder you want to ignore in the Local Changes view or in Project tool window. File colors in these views help you identify the status of the file.
Right click the selection and choose Git | Add to .gitignore or Git | Add to .git/info/exclude .
File colors in these views help you identify the status of the file.
If you need to exclude files by a certain pattern, or files of a certain type, you can edit the .gitignore or .git/info/exclude file directly. See .gitignore patterns format.
If you want ignored files to be also displayed in the Local Changes view, click on the toolbar and select Show Ignored Files .
Check project status
PyCharm allows you to check the status of your local working copy compared to the repository version of the project. It uses specific colors to let you see which files have been modified, which new files have been added to the VCS, and which files are not being tracked by Git.
Open the Local Changes view.
The Changes changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to the VCS but have not been committed yet (highlighted in green).
The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.
Track changes to a file in the editor
You can also track changes to a file as you modify it in the editor. All changes are highlighted with change markers that appear in the gutter next to the modified lines, and show the type of changes introduced since you last synchronized with the repository. When you commit changes to the repository, change markers disappear.
The changes you introduce to the text are color-coded:
line added.
line changed.
line deleted.
You can customize the default colors for line statuses on the Editor | Color Scheme | VCS page of the IDE settings Ctrl+Alt+S .
To disable VCS markers in the gutter, deselect the Highlight modified lines in gutter option on the Version Control | Confirmation page of the IDE settings Ctrl+Alt+S .
You can manage changes using a toolbar that appears when you hover the mouse cursor over a change marker and then click it. The toolbar is displayed together with a frame showing the previous contents of the modified line:

You can roll back changes by clicking and explore the differences between the current and the repository version of the current line by clicking .
Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.
Add a remote repository
If you created a Git repository based on local sources, you need to add a remote repository to be able to collaborate on your Git project, as well as to eliminate the risks of storing all of your codebase locally. You push changes to a remote repository when you need to share your work and pull data from it to integrate changes made by other contributors into your local repository version.
If you have cloned a remote Git repository, for example from GitHub, the remote is configured automatically and you do not have to specify it when you want to sync with it. The default name Git gives to the remote you’ve cloned from is origin .
Define a remote
Create an empty repository on any Git hosting, such as Bitbucket or GitHub. You can create a repository on GitHub without leaving PyCharm: see Share a project on GitHub.
Invoke the Push dialog when you are ready to push your commits by selecting Git | Push from the main menu, or press Ctrl+Shift+K .
If you haven’t added any remotes so far, the Define remote link will appear instead of a remote name. Click it to add a remote.
In the dialog that opens, specify the remote name and the URL where it will be hosted, and click OK .
Add a second remote
In some cases, you also need to add a second remote repository. This may be useful, for example, if you have cloned a repository that you do not have write access to, and you are going to push changes to your own fork of the original project. Another common scenario is that you have cloned your own repository that is somebody else’s project fork, and you need to synchronize with the original project and fetch changes from it.
From the main menu, choose Git | Manage Remotes . The Git Remotes dialog will open.
Click the Add button on the toolbar or press Alt+Insert .
In the dialog that opens, specify the remote name and URL and click OK .
To edit a remote (for example, to change the name of the original project that you have cloned), right-click the remote branch in the Branches pane of the Git Log tool window, and select Edit Remote from the context menu.
You can also edit a remote from the Push Dialog by clicking its name.
To remove a repository that is no longer valid, right-click it in the Branches pane of the Git Log tool window, and select Remove Remote from the context menu.
Manage projects hosted on GitHub
You can clone a repository that you want to contribute to directly from PyCharm and create a new project based on it.
From the main menu, choose Git | Clone . If the Git menu is not available, choose VCS | Get from Version Control .
In the Get from Version Control dialog, choose GitHub on the left.
Log in to GitHub by doing one of the following:
If you have a token, click Use token , then paste the token in the Token field, and click Log In .
Otherwise, click Log In via GitHub .
Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.
Select a repository from the list of all GitHub projects associated with your account and the organization that your account belongs to.
In the Directory field, enter the path to the folder where your local Git repository will be created.
If you want to create a project based on these sources, click Yes in the confirmation dialog. PyCharm will automatically set Git root mapping to the project root directory.
Share a project on GitHub
You can add a remote GitHub repository for a project you are developing locally, so that others can view it or contribute to it.
Open the project you want to share.
From the main menu, choose Git | GitHub | Share Project on GitHub .
If you have already registered your GitHub account in PyCharm, connection will be established using these credentials.
If you have not registered your account in PyCharm, the Login to GitHub dialog opens. Specify your access token or request a new one with your login and password.
When connection to GitHub has been established, the Share Project on GitHub dialog opens. Specify the new repository name, the name of the remote , and enter a description of your project.
You can select the Private option if you do not want to allow public access to your repository for other GitHub users.
Click Share to initiate a new repository and upload project sources to it.
Jump to the GitHub version of a file
You can jump from PyCharm to the GitHub version of a file. PyCharm detects which branch is currently active as well as the latest revision of the file, and opens the GitHub copy of the selected file in the corresponding commit in your web browser.
Do one of the following:
Select Git | GitHub | Open on GitHub from the main menu.
Select a file in the editor or in the Project view, and choose Open In | GitHub from the context menu.
Select the file in the Project view, press Ctrl+Shift+A , and type Open on Github .
If you are signed in to GitHub, the remote version of the file will open in the browser.
Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.
If you are opening the GitHub file version from the editor, the file will be also automatically scrolled to the current line.
If the file points to more than one remote, you will be prompted to select the appropriate repository.
Get started with an existing repository from GitHub in PyCharm
When working on programming projects, version control is very important. Git is one popular software that can be used for version control and collaborative work. When working on projects in PyCharm, Git can be integrated into the project so that you can do your work on PyCharm and once tested , then you can publish your work over the internet for the outer world to interact. It also protects your work in case anything happens to your local environment. Jump in !
Perquisites:
- You should have PyCharm installed on your machine.
- You have authorized PyCharm to communicate with your git repo through your login credentials or with token.
You can go to Settings -> Version Control -> GitHub
Or Go to Settings in GitHub . Then Developer Settings -> Personal Access Tokens
Now Let’s go to GitHub and create a repository
Let’s add a python program in this repo .
Now we will clone this repository into PyCharm and start our work there . Click code . Copy the HTTPS link .
Go to PyCharm and navigate to VCS to clone the repository
Paste the URL of the git repository , you want to clone
Now you can see the project on PyCharm .
Let’s edit something in this file and also add a new file
I added a file hello_in_japanese.py . It’s prompting me , do you want to add it to your local git repo. Let’s add it and then commit our change by pressing Ctrl+K
Before committing , we can review the change by using diff (two blue arrows)
- we added an additional line to the existing file
- we added a new file
Write some messages before committing
We are here now and yet to push our changes to remote repository
Status of logs
Observe the state of remote . It has only got record logs of the commit when we created the file when we created the repository in GitHub
State of local repo is at this stage as we added a new file and changed to existing file. It’s one commit ahead of the remote.
Push
Let’s now push the changes to remote by Ctrl+Shift+K and go to our remote github repository.
Now you can see the changed file and new files both are visible.
I will dive into , how can we do collaborative work between multiple branches using Git. Stay tuned.