Steps to upload local project to Github and pushing future project changes to existing Github repository

Steps to upload local project to Github and pushing future project changes to existing Github repository

3 min. read

Github is a website where you can upload you project files and keep track of your project's version eg. 1.0, 1.1 etc. It is a version control system.

In this article you will learn how to upload your project to Github and send the changes that you make in project in future to the existing Github repository.

Uploading project to Github

Follow the steps below

Step 1

Go to your Github account and create a new repository for your project.

Click on the plus button and then click New repository

Create new Github repository

Step 2

Give a name and an optional description for your project then click on Create repository button.

Name and description for the github project

Now you Github repository is created.

Step 3

On your pc go to your project directory using Command prompt or terminal(using cd command).

Step 4

Now you are in your project directory so issue the following commands one by one.

git init

This command creates a git directory in your project.

git add .

This command adds all the changes made in the project to the index to be included in the commit.

git commit -m "first commit"

This command records changes to the project you have made.

git remote add origin https://github.com/yourusername/projectrepository.git

Replace "yourusername" with your Github username and "projectrepository" with name of your Github repository that you created in step 2.

eg. git remote add origin https://github.com/fakeusername/project-repo.git

This command creates a new remote called origin located at https://github.com/yourusername/projectrepository.git.

In case if you get error saying "Remote origin already exists" try the command below
git remote set-url origin https://github.com/yourusername/projectrepository.git

Final command

git push -u origin master

This command pushes the commits in the local branch named master to the remote named origin.

"-u" lets you to point your local branch(master) to the remote master branch.

Now check your Github repository there you will find your whole project.

You have learned how to upload the project to Github, so lets continue to next part

Pushing changes in the project to Github repository

In future if you make changes in your local project(project in your pc) then to push those changes to the Github repository use the following commands

git add .
git commit -m "my commit"
git remote set-url origin https://github.com/yourusername/projectrepository.git

eg. git remote set-url origin https://github.com/fakeusername/project-repo.git

git push -u origin master

Now you have learned how to upload project to Github and push changes made in the project in future to the Github repository.

Write comments