How to Add an Existing Project to Github Repository?

In this tutorial, you will learn how to add your existing project to Github respository.

Follow the steps below to add an existing project to Github repository:

  1. Login into your Github account at If you don't have an account, create one by signing up.
  2. After you've logged-in, choose to Create a new repository or Start a project.
  3. On the Create a New Repository page, do the following:
    • In the Repository name field, enter the name of your project folder.
    • Next, choose the visibility for your repository. Select Public if you want your repository to be visible to everyone on the internet. If you do not want your repository to be visible to everyone but only to people you choose then select Private.
    • You can leave other options as it is. Example shown in the image below:
    • Create a new Repository Github
    • Click on the Create repository button and you will be taken to your newly created repository page as shown in the example image below:
    • New Github Repository
  4. Next, open a terminal (command prompt) and navigate to your project folder:
            cd my-project
  6. Now execute the following commands one by one. Do not forget to replace with your project repository HTTP address:
    echo "# my-project" >>
    git init
    git add
    git commit -m "first commit"
    git branch -M main
    git remote add origin
    git push -u origin main

    The above commands are explained below:

    The echo "# test" >> command adds file

    The git init command initializes an unversioned project repository as a new git repository.

    The git add . command add changes of files for the next commit. The git add . means add all the files.

    The git commit -m "first commit" saves changes to the local repository with a commit message.

    The git remote add origin command adds github remote project repository address (Do not use ssh, use https). Replace the address with your project repository address.

    The git push -u origin main command publishes your local project changes to the remote main branch of your project repository on github.

  8. You may be prompted to enter your username and personal access token if your repository is Private. To know how to generated a personal access token, see here.