15
How to add a remote Github repository to local
You might have been given a task to accomplish using github classrooms or created a remote repository on github and you are wondering how to push your local project to the remote repository. In this article i will quickly show you how to accomplish that task. Sit tight.
On the terminal of your ide . you will want to initialize the local directory as a git repository by using this command.
git init -b main
This command converts your local repository into a git repository. The next thing you would want to do is add the files you have in your local repository into your git repository by committing them. Before committing the files you would first have to add them . The command for adding is below
git add .
After adding the files you then commit it to the local git repository by using the command:
git commit -m "First commit"
First commit represents the commit message. it is usually a short title that is an overview of what you have done. This local commit also prepares the files to be pushed to a remote repository.
At the top of your github online repository setup page you would see the repository url . either HTTPS or ssh. depending on your organization's requirements
![](https://res.cloudinary.com/practicaldev/image/fetch/s--c8eVJS4T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nj3zwsf3csuzmf5oczkm.png)
You would need to add the url you have copied to your local github repository by using the below command.
git remote add origin <REMOTE_URL>
Then verify the remote url
git remote -v
After adding the url to the local github repo. You can then push your changes to your online repo by using the below command
git push -u origin main
With main being the name of the branch online you are pushing your local changes to
Thank you very much and i hope this article helps you with your first steps in github. I am always free to answer questions and help. you can check my profile out on twitter
@rake_code
15