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:
- Login into your Github account at https://www.github.com. If you don't have an account, create one by signing up.
- After you've logged-in, choose to Create a new repository or Start a project.
- 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:
- Click on the Create repository button and you will be taken to your newly created repository page as shown in the example image below:
- Next, open a terminal (command prompt) and navigate to your project folder:
- Now execute the following commands one by one. Do not forget to replace https://github.com/tutorials-buddy/my-project.git with your project repository HTTP address:
- 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.


cd my-project
echo "# my-project" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/tutorials-buddy/my-project.git
git push -u origin main
The above commands are explained below:
The echo "# test" >> README.md command adds README.md 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 https://github.com/tutorials-buddy/my-project.git 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.