How to Push a Project to GitHub using terminal
Tags: github, newbie, tutorial, git
Published: 2021-03-01 13:49:37

---
title: How to Push a Project to GitHub using terminal
published: true
description: 
tags: Github, Newbie, Tutorial, Git
//cover_image: https://miro.medium.com/max/875/0*UFKt2A0r8xxJTQV0
canonical_url: https://sameerkatija.medium.com/how-to-push-a-project-to-github-d099523eb5b7
---

GitHub is the cloud-hosted Git management tool and git is Version Control System as we discussed previously. 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 [article](https://dev.to/sameerkatija/an-introduction-to-git-and-github-for-newbies-15n2). If you have already set it up. Let’s continue.

## Step 1: Create a GitHub Repo

In order to push our code to Github, we have to create a Github Repo. You can create Github Repo by simply going to this [link](https://github.com/new). Choose your project name and add a description, if you want to, and click on create the repository.

![Create a GitHub repo](https://miro.medium.com/max/875/1*oKDnX6eRhx7DrXa4RDkrmw.png)

## Step 2: Initialize Git in the project folder

Initialize the project folder as a git repo. To do that you need to navigate to the folder which you want to push on Github. There type the following command

``` 
git init
```
![initialize github](https://miro.medium.com/max/875/1*qYHKi2FfZC2Rm4XlZCyhwQ.png)

If you have already initialized the repo as git, you can skip this step.

## Step 3: 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.

```
git add -A
```

![Add the files to git staging area](https://miro.medium.com/max/875/1*D47ElyqdaGstUzuOWySULw.png)

This command will add the file to the staging area and “-A” means you want to include all the files. if you want a specific file to be staged then you need to add the file name after git add.

```
git add abc.txt
```

## Step 4: 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”
```

![commit the staged files](https://miro.medium.com/max/875/1*Bn_3k9oPPRpLdDurniiAcg.png)

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

## Step 5: Add the remote origin

After creating the repo on GitHub, you will see the windows containing some instructions and also the address of your repo.

![Address of GitHub repo](https://miro.medium.com/max/875/1*oEMbPoYd2ceIQvGetJwyww.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/Anonster/jadu-01.git
```

In your case, the address should be of your GitHub repo.

![Git add remote origin](https://miro.medium.com/max/875/1*w1zDj9NEj6PMFbvWCwXEkg.png)

## Step 6: Push to GitHub

Now, it’s time to make our code live. 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
```

![Picture showing repo branches](https://miro.medium.com/max/875/1*9d-W9iFx9MinRD3nOsMrgw.png)

In my case, it’s master but in your case, it can be main. so if your branch is “main ”type

```
git push origin main
```

If your repo’s branch is “master ”then you need to type

```
git push origin master
```
![Git push origin master](https://miro.medium.com/max/875/1*uRvy6G05UWhjkZF8y9u4jg.png)

With all that, you have pushed your code to Github. You can share your code with anybody you want.