1. Open a web browser on your Ubuntu 18.04 LTS machine and login to your account at GitHub.
2. Once logged into your account, you will be greeted by your account dashboard. We can create our new repository from this page. Locate the green button that reads, “New repository” and click it.
3. We are taken to the “Create a new repository” page. The first thing that we need to do is name our project. Feel free to name the project whatever you like. I will name mine “my_first_github_project.”
4. Below the repository name, we have the option to add a description of our project. Add a description if you wish. I am adding the description, “Hello, World! This is my first GitHub project!”
5. Beneath the description, we must choose between a public or private repository. The private option means paying for a subscription, so we will choose the “Public” option.
6. Next, we will select to initialize the repository with a README file. The README file will allow you to add notes, instructions, or anything else that you like.
7. After choosing to initialize the repository with a README file, click the grey button beneath the README file section. A search input with options in alphabetical order appears. Type the following into the search field:
8. Select the Python option that appears. To the right of the button we just chose Python from is the button to add a license to our project. Click the button to open the list of available licenses and a search input. Since our simple Python project will not contain any super secret algorithms or other proprietary code, the GNU General Public License v2.0 will suit our needs just fine.
9. Select the GNU General Public License v2.0. With everything we need to create our new repository complete, click the green Create repository button at the bottom of the page.
10. Your repository is now created and you are taken to the repository’s project page.
11. The next step is to clone the newly created repository to our Ubuntu 18.04 LTS system. To begin the process, click the green Clone or download button on the right side of the page. Copy the link to the repository to your clipboard by clicking the small copy button next to the link that appears after clicking the green Clone or download button.
12. Now that we have the link to our repository copied, we can clone the project to our Ubuntu 18.04 LTS machine. Open a terminal and enter the following command, replacing <Copied_Repo_Link> with the actual repository link that you copied in step 11:
git clone <Copied_Repo_Link>
13. The output of the previous command should look similar to this:
14. Move into your project’s directory by entering the following command, replacing <My_Project_Name> with the actual name of your project:
15. Once within your project’s directory, we can create our Python file. Enter the following into the terminal to create the Python file:
16. Verify the Python file was created by entering the following into the terminal:
17. Next, we will open and edit the project.py file with nano, a very nice, user-friendly text editor that ships pre-installed on Ubuntu and Ubuntu based operating systems. Open the project.py file in nano by entering the following command into the terminal:
18. When the nano text editor opens, enter the following line of Python code to the file:
print(“Hello, World! This is my first GitHub project!”)
19. Close the file by entering CTRL + X. Enter Y to save the changes to the file, then press Enter on your keyboard to keep the name of the file.
20. Since we should only be pushing working code to our GitHub account, test your Python project by entering the following into the terminal:
21. As you can see, our Python program worked, and displayed the text, “Hello, World! This is my first GitHub project!”.
22. Now we can add our changes so that they are tracked by entering the following into the terminal:
git add .
23 Let’s make sure that our changes are being tracked. Enter the following into the terminal to view the status of our project:
24. As we can see from the image above, our project.py file is staged for commit. To commit the file to our repository, enter the following into the terminal:
git commit -m “Initial Commit”
25. The output of the previous command should look similar to this:
26. Finally, we can push our changes to our repository on GitHub to share with the world! Enter the following into the terminal to begin the process of pushing the project:
27. Before the push will complete, you must enter your GitHub account username and password. Enter these details when prompted.
28. The changes to our first GitHub project will push to our repository and the output of the previous command should look similar to this:
29. The final step is to return to the web browser and view our project on GitHub again, now that the changes have been pushed. As you can see, our project.py file is now present in our GitHub project’s repository!
30. Clicking on the project.py file will open the file, exposing the code that we entered.
Congratulations, that’s all there is to creating our first GitHub project! View the repository for this project here.