Assuming that you have created your remote repository on Github, Gitlab, Bitbucket, Gitea, Gogs, or any other popular services that let you host your Git repositories. In this example we will see by using most common provider Github.
Once you have created the repository you will be able to see the instructions on their sites.
There are two protocols you can use when working with Git; HTTPS and SSH.
Not sure which protocol to use? Check out this article on the GitHub Help site.
Note: Make sure you’re in the project’s working directory on the command line before proceeding with the next steps.
You’ll need to enter your GitHub username and password every time you clone, fetch, pull or push to a remote repository using HTTPS URLs.
To add the remote repository URL, type the following command making sure to replace the HTTPS URL with the one for your own project.
git remote add origin https://github.com/bhavik/laravel-demo.git
Once you’ve done that, type the following command to add the remote repository URL. Make sure you replace the SSH URL with the one for your own project.
git remote add origin firstname.lastname@example.org:bhavik/laravel-demo.git
Once you’ve added the remote repository URL using you preferred protocol, it’s time to actually push your repository to GitHub.
git push -u origin master
A few seconds later, you should see output like this:
Counting objects: 227, done. Delta compression using up to 8 threads. Compressing objects: 100% (125/125), done. Writing objects: 100% (227/227), 644.39 KiB | 89.34 MiB/s, done. Total 227 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), done. To github.com:bhavik/laravel-demo.git * [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'origin' by rebasing.
-u origin master part of this command essentially links your local
master branch with the
master branch on the
Note: The name “origin” is just a convention used by developers using Git – you don’t need to worry about it too much.