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 tha…


This content originally appeared on DEV Community and was authored by Samuel Ochuba

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 initialiase 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

Alt Text

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


This content originally appeared on DEV Community and was authored by Samuel Ochuba


Print Share Comment Cite Upload Translate Updates
APA

Samuel Ochuba | Sciencx (2021-07-01T01:44:37+00:00) How to add a remote Github repository to local. Retrieved from https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/

MLA
" » How to add a remote Github repository to local." Samuel Ochuba | Sciencx - Thursday July 1, 2021, https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/
HARVARD
Samuel Ochuba | Sciencx Thursday July 1, 2021 » How to add a remote Github repository to local., viewed ,<https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/>
VANCOUVER
Samuel Ochuba | Sciencx - » How to add a remote Github repository to local. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/
CHICAGO
" » How to add a remote Github repository to local." Samuel Ochuba | Sciencx - Accessed . https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/
IEEE
" » How to add a remote Github repository to local." Samuel Ochuba | Sciencx [Online]. Available: https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/. [Accessed: ]
rf:citation
» How to add a remote Github repository to local | Samuel Ochuba | Sciencx | https://www.scien.cx/2021/07/01/how-to-add-a-remote-github-repository-to-local/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.