How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

June 24, 2018
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

“How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS” covers the entire process of creating and cloning a GitHub repository, creating a simple Python project, and committing and pushing the Python project to the repository we create. This tutorial assumes that you have already created a GitHub account and have installed and configured Git on your Ubuntu 18.04 LTS system. If you have not done these things yet, please follow this tutorial before continuing with this one. Creating a repository on GitHub for our projects allows us to collaborate with others on projects, record changes and updates to code, and serve as an offsite backup for our projects. It also allows updates to be easily pulled to production servers, saving time and headaches.

1. Open a web browser on your Ubuntu 18.04 LTS machine and login to your account at GitHub.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.”

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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!”

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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:

python
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

10. Your repository is now created and you are taken to the repository’s project page.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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>
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

13. The output of the previous command should look similar to this:

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

14. Move into your project’s directory by entering the following command, replacing <My_Project_Name> with the actual name of your project:

cd <My_Project_Name>
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

15. Once within your project’s directory, we can create our Python file. Enter the following into the terminal to create the Python file:

touch project.py
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

16. Verify the Python file was created by entering the following into the terminal:

ls
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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:

nano project.py
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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!”)
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

20. Since we should only be pushing working code to our GitHub account, test your Python project by entering the following into the terminal:

python3 project.py
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

21. As you can see, our Python program worked, and displayed the text, “Hello, World! This is my first GitHub project!”.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

22. Now we can add our changes so that they are tracked by entering the following into the terminal:

git add .
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

23 Let’s make sure that our changes are being tracked. Enter the following into the terminal to view the status of our project:

git status
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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”
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

25. The output of the previous command should look similar to this:

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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:

git push
How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

27. Before the push will complete, you must enter your GitHub account username and password. Enter these details when prompted.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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:

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

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!

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

30. Clicking on the project.py file will open the file, exposing the code that we entered.

How to Create a GitHub Repository and Commit a Project on Ubuntu 18.04 LTS

Congratulations, that’s all there is to creating our first GitHub project! View the repository for this project here.