DEV Community

Cover image for How to add an existing project to GitHub
Madiha Eram
Madiha Eram

Posted on

How to add an existing project to GitHub

So this is for the beginners as I've already added the tag,so I'll tell you in a simple way
So first of all why we use GitHub because it has lots of advantages like 'It makes easy to contribute to your open source projects,it has Documentation where we can explain our project or tell about our project and also showcase our project also the biggest advantage is that if you add lots of project then you may get a job by github(or whoever the boss is😅).
So now we do our job the topic which is yet there to discuss
Github
1.Login your GitHub a/c and create a new repository
Do not initialize your new repository with README or other files. You can add those files later.
New Repository
2.Go to Terminal and switch to your local project that you want to push by typing the following command:
cd PATH_TO_YOUR_PROJECT_FOLDER

3.And after that when the folder of your project is shown then type the command below to initialize your folder as a git repository.
git init

4.Then add all the files to the staging area known as index, to prepare them for the next git commit.
git add .

5.Next step is that you need to commit the files that you previously staged by running:
git commit -m "First commit"

(This will only commit to your local branch)

6.Go to the GitHub repository that you’ve just created and copy the remote repository URL.

Eg:
https://github.com/madihaeram/My-first-App.git
Repository Link

7.In Terminal, type the command below followed by your remote repository’s URL where your local repository will be pushed.
git remote add origin YOUR_REMOTE_REPOSITORY_LINK

8.Verify the new Remote URL by typing:
git remote -v

9.Atlast, Push your local project up to the remote repository you specified in the step 7 by typing:

git push -u origin main

Thank you for reading this tutorial,Hope you find this helpful.

Top comments (0)