Linking to Github
PyCharm allows you to connect your GitHub account and manage your GitHub projects directly from PyCharm. This GitHub integration saves you time when managing and contributing to different GitHub repositories.
TABLE OF CONTENTS
- Connect your GitHub account
- Control multiple GitHub accounts
- Share your project on GitHub
- Clone an existing project to Pycharm
Recommended
Make sure you have an existing GitHub account before proceeding.
Connect your GitHub account
From the project workspace, go to File -> Settings to access the main settings for PyCharm
Go to Version Control -> GitHub. Click on the + button to add a GitHub account.
Choose and click on either Option A or Option B to log-in to your GitHub account.
STOP
PyCharm provides two options to add a GitHub account. A) Log-in with your GitHub credentials B) Log-in with a personal access token
RECOMMENDED
This guide recommends **Option A** as this option is the quickest method. Option B serves as an alternative method should you fail to log-in with Option A.
Option A - Log-in with GitHub Credentials
Click Log in via GitHub….
PyCharm will redirect you to another page.
Enter your GitHub account credentials. If successful, PyCharm will automatically add your GitHub account.
Option B - Log-in with Personal Access Token
Go to GitHub and log-in to your GitHub account.
Click on your profile picture located at the top right corner and click on Settings to access your account settings.
Click on Developer Settings located at the bottom of Account Settings.
Click on Personal access tokens -> Generate new token.
Create a suitable name for this access token (eg. pyCharmToken). Check the box for the following scope options: repo, workflow, read:org, and gist
STOP
Make sure that **repo**, **workflow**, **read:org**, and **gist** are checked off. The access token may not work correctly if these four scope options are not selected.
Press Generate Token to confirm your access token settings.
Copy the access token by clicking on the blue clipboard icon.
CAUTION
Keep your access tokens confidential as the tokens provide access to your GitHub account! For security reasons, this newly generated token is **ONE TIME ACCESS** only. Ensure you have copied the key or you will have to generate another access token.
In PyCharm, click Log in with Token….
Paste your access token in the box and presss Add Account.
Verify your GitHub Account Log-in
Confirm your GitHub account details displayed next to the light blue arrow. Press Apply and press OK to save your changes.
Control multiple GitHub accounts
- Add multiple GitHub accounts by pressing the + button and follow the same steps as described in the previous section.
Delete a GitHub account by selecting the intended account and press the - button.
Set a default GitHub account be selecting the intended account and press the check button.
Share your project on GitHub
STOP
You must have linked an active GitHub account before proceeeding.
Select and open the intended project that you want to share.
From the project workspace, go to VCS -> Share Project on GitHub.
In the new window, provide the following project information to create a repositiory on GitHub.
Give a name for the repository where your project will be located on GitHub.
STOP
You have the option to set the your repositoriy visibilty to private by checking **Private** on the right hand side.
Provide a project description.
Press Share to confirm your changes.
Provide a commit message and press Add to add the project files to the repositiory.
Wait for PyCharm to upload your project files to the GitHub repository. A window will pop-up in the lower right hand corner to indicate your project has been succesfully shared on GitHub.
To verify your project, click on the project name in the above screenshot. You will be directed to the GitHub project repository.
Clone an existing project to Pycharm
Go to the GitHub repository page of an existing project.
Click on the CODE button to access the git url. Click on the clipboard icon to copy the url.
From the PyCharm welcome page, click on Get from VCS to access the Version Control settings.
Click on Repository URL. Select the Git option for Version control.
Paste the copied git url from Step 2 into the URL box.
Select where the cloned project will be stored in your directory.
Press Clone to copy the GitHub project to your computer.
Success! You have now cloned an existing GitHub project to your local computer.