Skip to main content

Adding Existing Project to GitHub using Mac Terminal

Steps to add your existing project to GitHub are similar, no matter if you are using git bash on Windows or any other CLI on any OS. In this video we will commit our existing project to GitHub using Mac Terminal. If git is not already installed on your MAC System you can follow this link.

Step 1: First you have to create a new repo or if it is already created by someone in your organization you can skip this step. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.

repo button on github

create repo steps github

Step 2: Now go to your mac terminal and in your project directory.

Step 3: Intialize the local directory as your git directory

$ git init -b main

Step 4: Add files to your new local repository

$ git add .

Step 5: Commit the files you have staged in your local repository

git commit -m "First commit"

Step 6: Visit github.com and copy URL from code section or you will find it at top for new repo.

locate repo URI github

Step 7: In terminal replace <REMOTE_URL> with URL you have copied

$ git remote add origin  <REMOTE_URL> 
$ git remote -v

remote -V is to verify the new remote URL.

Step 8: Push changes to github using below command.

$ git push -u origin main

Refresh on GitHub to see your changes.

Submitted by tgoswami on January 11, 2022

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.