How to Share The PyCharm Project on Github

A simple way to share your project on GitHub using PyCharm

Eko Misprajiko
Analytics Vidhya
7 min readMar 31, 2020

--

How to Share The PyCharm Project on Github

In this article I will tell you about How to share The PyCharm Project on GitHub.

If you don’t know what GitHub is, please read a little of my explanation about GitHub below. However, if you already understand and just want to know how to share your Pycharm Project on GitHub, then please skip this section and keep scrolling down until you find what you are looking for. Then, if you don’t find what you’re looking for, chances are you’ve lost. lol

Okay, what is GitHub?

GitHub, Inc. is a US-based global company that provides hosting for software development version control using Git. It is a subsidiary of Microsoft, which acquired the company in 2018 for US$7.5 billion. It offers the distributed version control and source code management functionality of Git, plus its own features.” Wikipedia

In the definition of GitHub above it is mentioned that GitHub uses Git.
Hmm … Then, what is Git?

Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.” Wikipedia

After you know the meaning of GitHub and Git, maybe you will think why bother with sharing to GitHub?

OK, some reasons you have to upload your project to GitHub:

  1. Reduce hard drive memory on personal laptops. When we work on a project it is not uncommon that the project is just lying on a laptop which may take a long time for us to open the project. Instead of fulfilling the hard drive project, we better save it to GitHub, right? After all, the capacity provided by GitHub is quite large. For GitHub capacity management you can see it here.
  2. The project that you created can be big on its own. Many people are looking for free projects on GitHub, and if that person considers your project interesting, it’s not that he or she will be a contributor to developing your project.
  3. You will develop your project with the team. With GitHub you will be easier to manage the division of tasks. Please learn more by browsing the internet.
  4. Projects that you share on GitHub can become your portfolio. If you are a student who, when you graduate, wants to work in a company or become a freelancer, then you can show the project that you have saved on GitHub as your portfolio. Surely you will have more value right?

Mmm … maybe there are still many more reasons to share the project with GitHub, but the article might be too long and does not reach the core of how to share the PyCharm project on GitHub.

This is too long. lol

Okay let’s practice!
As usual, there are a number of preparations you must make before moving on to how to share the PyCharm project on GitHub:

  1. Of course you should already have a PyCharm project first. If you don’t have a project, you can use the project in the article How to Master Web Scraping using Python in less than 30 minutes. I also used the project in this article. But I do not recommend you to download it directly from my GitHub, because there are already a number of files that will actually be created in this article.
  2. You must already have a GitHub account. If you don’t have a GitHub account, please register first here.

Yes, that’s all the preparation. If you already have everything I mentioned above then you can start the steps to share the PyCharm Project on GitHub.

Come on coding now!
FIRST STAGE — CREATE .gitignore FILE
The .gitignore file serves to ignore some things that we don’t need to save or push into GitHub. Why? Because not everyone uses PyCharm as an IDE to build applications in Python, so we don’t need to save files and folders like .idea, venv, etc. on GitHub. It also can reduce our storage capacity on GitHub. Following are the steps to create a .gitignore file using PyCharm:

1.Create new file named .gitignore with the steps according to the following image:

Create New File
Create New File
Name the file with .gitignore
Name the file with .gitignore

2. There have been many people who have created the .gitignore file, you can search on Google with the keyword “gitignore python pycharm” then there will be many choices similar to the following image:

Python PyCharm .gitignore
Python PyCharm .gitignore
MOOWOO/py-gitignore
MOOWOO/py-gitignore

3. In this article I use .gitignore from MOOOWOOO. You can immediately see the raw contents through this link here.

4. Copy all raw contents:

Copy all raw contents
Copy all raw contents

5. Paste into the .gitignore file that we made earlier:

Paste into the .gitignore file
Paste into the .gitignore file

6. Congratulations, the .gitignore file creation is complete.

SECOND STAGE — CREATE requirements.txt FILE
Because we use .gitignore to ignore some things, when someone downloads the project to our GitHub, he has to install the needs related to the library or package that we use on the project. Well, that’s where the function of the requirements.txt file, that we will make at this stage. Here are the steps:

1.Press Terminal in the lower left corner of the PyCharm toolbar as shown below:

Pycharm Terminal
Pycharm Terminal

2. Still referring to the picture above, type the pip code freeze > requirements.txt, then press Enter.

3. Wait until a blank line appears as shown in number 1.

4. Check on the project whether the requirements.txt file already exists:

Content in requirement.txt file.
Content in requirement.txt file.

5. If it already exists, when you open the file it will contain the packages or libraries needed to make the application run correctly.

6. If you don’t have it please press the down arrow in the project folder twice to refresh the contents of that folder.

7. If it still doesn’t appear, you can do the Invalidate caches / restart PyCharm via the File menu as follows:

File > Invalidate caches / restart
File > Invalidate caches / restart
Choose Invalidate caches and Restart
Choose Invalidate caches and Restart

8. PyCharm will restart your project.

9. If it still doesn’t appear again, maybe you’re not in luck, lol. Please repeat again from step number 1.

10. Okay, making requirements.txt complete!

THIRD STAGE — SHARE PROJECT ON GITHUB
Okay, here’s what you’ve been waiting for. After successfully passing the above stages, the next is how to share the PyCharm project on GitHub. Check this out!

1.Make sure you have logged into your GitHub account through a browser (I use Google chrome). This will serve to ensure the success of this stage.

2. Click VCS > Import into Version Control > Share Project on GitHub on the PyCharm menu like this:

Share Project on GitHub
Share Project on GitHub

3. Furthermore, in order for PyCharm to create a repository in your GitHub account, you must register it in PyCharm (you are only required to log in with your GitHub account), as follows:

Login to GitHub using PyCharm
Login to GitHub using PyCharm

4. Next you will be asked to create a Repository name (this is just another name for the Folder) and Project Description. Usually it will automatically use the name of the PyCharm project name:

Create a Repository (Project Folder)
Create a Repository (Project Folder)

5. After you click Share (see the picture above), you will be asked to choose what you want to share to GitHub (just select all). After you have finished choosing, please click Add:

Initial Commit
Initial Commit

6. Wait for the upload process to finish, marked with a notification in the lower right corner of PyCharm as follows:

Successfully shared project on GitHub
Successfully shared project on GitHub

7. After the notification appears like in the picture above, please check the list of repositories in your GitHub account through the browser, and yes you get it:

Your project is now on GitHub
Your project is now on GitHub

8. Okay, done guys! Goodjob!

How easy, right?

What, you say hard?
Okay, okay, I’m sure you’re just kidding right?

It seems that this is all I can give in the article on How to Share the Pycharm Project on GitHub.

Of course there are many other ways to suit different situations and conditions. So that you are more developed, please explore other ways yourself.

Thank you for reading.
See you next time and Happy Coding!

--

--