How to push your project to github
Tags: beginners, webdev, github, programming
Published: 2022-04-24 12:08:57

## Introduction
Github helps us to share and store our code easily. Today we will learn how we can push a project which is stored locally to a remote server or github. Before we push the project to Github, we need to *configure* and *install* git on our computer and you also need a GitHub account. 

If you don’t know how to configure and install git read this [Introduction to git and github](https://dev.to/ezekiel8807/introduction-to-git-and-github-1f70). If you have already set it up. Let’s continue.

Below are few steps to take to push our project to github
- Create a github repo

- Initialize Git in the project folder on your local machine

- Add the files to the git staging area

- Commit the staged files.

- Add the remote origin

- Push to GitHub

### Create a github repo
The first step in pushing your project to github is creating a 
github repo. you can do that by following this [link ](https://github.com/new). fill information such as _project name_, _description_ if you want to, and click on create the repository.

![a](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adb02fiyvnyfmqdvuxbd.PNG)

![b](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/teoxgfm9axgjgdngd47c.PNG)

### Initialize Git in the project folder on your local machine
To initialize git in your project, open command line in the root directory of your project and type the command below

```git
   git init
```

![c](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atkgv4qoaocp23koo4rd.PNG)
if you see this, it means you have now initialize git in your project.

### Add the files to the git staging area
Add the files to the git staging area, where all the untracked files will be part of the staging area and will be ready to get tracked.

```
touch readme.md
git status
```
The *touch* is a command in git command line follow by the file name with his extension to create a file.
This command *git status* is used by git to track files.


![d](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qhlu0jse23pmb3bt6j2.PNG)

Now the file created is colored red meaning its untrack, so let add the file to the staging area so it could be track by git.

```
git add 'file name'
```
```
git add .
```
The *git add 'file name'* is used to add a single file by its *name.extension* while *git add .* is used to add all file at once to the staging area.

![e](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vp46fenpy87tyy6h91u9.PNG)

### Commit the staged files
Commit in git-speak, is the term used for saving changes. Git doesn’t add changes automatically. You need to specify which file and changes, you need to save by adding the files. The commit command saves changes in the local repository of Git.

```
git commit -m “Initial Commit”
```

![f](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jcwsdv9b2frmepzkegyk.PNG)

In this command “-m” is used to tell the git, that we are adding a message.

### Add the remote origin 
Now to go to github to copy the link to our repo or click [here](https://github.com/Ezekiel8807/web)


![g](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4emry2q5gdgv5w5g0kf.PNG)

After copying the address, you have to add the origin of the remote repo to the local repo by using the following command.

```
git remote add origin https://github.com/Ezekiel8807/web.git
```
this address should be the address of the repo you created on your github account.

![h](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhm5pusxev2xfoi3lal9.PNG)

### Push to GitHub
This is the last phase, now type the following command to push your code to the online repo. Before we push we need to check whether our branch is main or master to check that type the following command.

```
git branch
```

![i](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btjue6usdqgg3n413vbe.PNG)

In these case my branch is "master" yours might be "main". To push your project use either of the two command below base on your branch name.

```
git push origin main
```

```
git push origin master
```


![j](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7s31nbvwzbe2z6r3o3v.PNG)

if you see this, congratulaton your project is now life. you can now share with friends or other developer. 

finally let check the project we push to github by clicking [here](https://github.com/Ezekiel8807/web)


![k](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fu0abrhswqjr0m7gtool.PNG)

So far, we have been able to cover how to push our project to github in continuation of the last article [INTRODUCTION TO GIT AND GITHUB](https://dev.to/ezekiel8807/introduction-to-git-and-github-1f70). Please do comment, like and share.