It’s obvious for the Data Scientist like you to work in projects with the version control. And besides this, you must be using the Python language as a major programming language. You know that there are many Python IDEs available in the market for making faster programming. PyCharm is one of them and it’s very popular among the programmers. Therefore in this post, you will know how to integrate GitHub with PyCharm in very simple steps.
Step 1: Download the Git Version Control Software
It is an open-source version control software. It is useful for creating version control locally. Popular companies like Google, Amazon, Netflix, and Facebook are using it. I will not get in details to give entire information about GIT. Just download it and install it on your computer. 🙂
Step 2: Make New or Edit Existing Projects
In this step, I will create a new Demo Project and enabling version control on it. If you have an existing project you can follow the same process. I created a new Project with the name GitTutorial. It has a two Python Script ‘print_number.py‘ and ‘print_text.py‘ for tutorial purpose. Now after creating it just follow the steps to enable version control on it.
Go to the menu bar and click on the VCS > Import into Version Control > Create Git Repository. Then it will ask for Folder selection. You can choose your existing folders but I am selecting the newly created Folder GitTutorial.
After selecting the desired Folder, all files inside that folder will turn red.
What is it mean? It means that all these files are not added to the version control. To add the files right click on the file and click on Git>Add. After adding the files you will see the file turn green. It means the file has been successfully added to the version control. Similarly, you can add all the existing files.
You can also add all files inside the folder by selecting that folder and click add.
The next thing after adding the files is to finally commit the files. You can commit single or multiple files. Right click on the folder or a single file and click on Git>Commit File. It will open the window like below.
In the first, you have the option to select or unselect files or Folder. In the commit message, you can put the message( text) in it. For example, I am writing Initial commit. At the bottom, you will see the Diff. Here you can see the previous versions of the code ( Any code Changes). After committing all the Files will go back to default color from Green Color.
Step 3: Integrate Github with PyCharm
All the above steps will lead you to create version control of the project locally. The only local user can add and commit. What if you want to share the code with the other user? Then you will use Github. Github is a cloud version control that is Cloud repository. Now if you want to integrate Github with PyCharm then follow the process done in this section.
Cloning and Pulling From Github
To integrate Github with PyCharm just goto VCS>Checkout from Version Control and Select Github. It will open up the window like below. Select the authorization type Password and enter your Github username and password. Select the desired repository URL. Now you can clone and Pull all the Files from that Url.
Pushing to the Github
Now the next thing is How to Push the Files created and committed in Step 2 to Github. To do this you have to Push the Files and Folder to the Github URL. Right-click on the File and Goto Git>Repository and click on Remotes. It will open up the window. Fill the Name of the Repository (It can be anything.) and URL of the repository. In this example, I have added the name as GitTutorial and Github URL. It will check the URL and it will be added if it exists.
Now the final task is to push the files created in step 2 to Github Url. To do this Goto Git>Repository and click on Push. Select the name of the previously added repository (GitTutorial) and click on Push. After some time it will ask for access to the Github. Put there your username and password and Login. It will successfully Push all the committed files in Step 2 to your Repository URL. In the same way, you can pull the changes from Github URL by going to Git>Repository and clicking on Pull.
Hurray! You have successfully integrated Github with PyCharm. I hope this article has solved your problem on How to Integrate Github with PyCharm. There are also other version control tools that you can integrate with Pycharm they are Mercurial and Subversion. But Integration with Github is Popular. If you any questions on Github and PyCharm then please contact us. We are always ready to help you. In the meantime, you can subscribe and like our dedicated Page on Data Science.