How to create a Github repository and push a project to it

Posted on

A repository can be defined in simple terms as a storage location for software packages which is used for version control.Repositories are hosted on Github which is a web-based platform used for version control and collaboration .Github is used by most developers as it allows them to host their files on cloud and work on projects with others.

In this article, I am outlining how to create a repository on GitHub and push code files from a local machine to it. Start by creating a folder with files in your machine and open the folder in VScode, or another editor of your choice.

luke chesser

To access GitHub, one must create a GitHub account. A GitHub account is important to a developer because it can be used to:

Showcase their work

Many developers look for customers through their github profiles. Recruiters also rely on the profiles to search for candidates to employ . A good Github profile can give a candidate a higher chance of getting employed.

Store projects through the repositories

GitHub is a great place to store one’s projects through repositories.Developers can utilize it to get their work to the cloud and give public access and global exposure to it.

Track changes through version control

GitHub is great because it keeps track of the changes and revisions done on a can indicate what has been changed, where, and when during the project development.

contribute to open source projects

Many open-source projects use Github to allow others to use or make contributions to them. To contribute to a project one has to fork the repository, make changes and send the owners a pull request.

One can create a GitHub account by signing up on

Before signing up, ensure that you read and understand the information about the different products and subscriptions that GitHub offers, then click the join button under the subscription you’d like to choose. Then follow the prompts to create your personal account or organization. You can begin with a free plan which has basic features for individuals and organizations.Oher plans include team and enterprise that are paid monthly.

Go to your GitHub account and create a new repository. You can give it a description, make it private or public, and initialize it with a README message or not.

Now there are two folders, one on Github and the other created locally on your computer. They need to connect to each other. Read the instructions provided on Github and follow the first one because it is appropriate for this task. But before starting the procedure, ensure that you have git installed in your computer.

Open cmd check if you have git by typing git or git –version

Locate the folder you created in step 1 using a terminal. Type ls to access the list of everything inside the current folder.

Use the command cd (change directory) to access the specific folder and type or copy-paste the command Git init to convert the file into a git file. Keep on following the instructions on the repository page.

.Create a README file or skip and just start committing your project.

Type git status to see if the files are saved on git.

The files are staged but unsaved.

Type git add . to add the files from VS Code to git.

Type git status to check if they are saved. Again if you are unsure of the files you are committing, you can use git reset to clear the files that are staged.

The green colour indicates that files have been staged ready to be pushed to github.

Commit the folder to deploy it to GitHub. Type git commit -m “push my project to github”. The message in brackets is attached to show what the current folder is all about. It helps people who access your project to understand the current state of the project.

Identify which branch you are pushing to by typing git branch -M main. Check the branch by typing git branch. It should indicate that you are on the main branch.

Now, we want to link the local git folder to the cloud git folder. Copy the second last line with HTTPS link on the repo instructions, paste on the terminal, and press enter.

Do a git remote -v to check if they are linked successfully.
Copy and paste the last instruction; git push -u origin main

The file has been successful pushed to github .Refresh your github to check if the repository now has files.

We have successful created a new repository and pushed a project to GitHub.

Gravatar Image
Justina Kageni is an information scientist with passion for Information Technology.She is on a mission to share her knowledge and skills.

Leave a Reply

Your email address will not be published. Required fields are marked *