Suppose we have existing project and we want to mange it with git and github. We already setup our local and initialized git on our project. Also we have created new repository in github and we already have the repository URL. To do so we enter the command and give a name to our github repo and finally the link:
git remote add origin https://github.com/HamidMirghafoori/git-in-action.git
By convention the remote name is set to "origin", but you can use any name. However, in case you look for tutorials and documentations, most of them are using the name origin , so it will be less confusing to follow the lessons if you also use origin.
Note:
When we clone a repo, the remote will be added automatically Also note that, here we have a complete new repo on remote, therefore, there would be no error for the pushing the code, if repository already has some files, then it requires another measurements based on what we really want to do! We will discuss them later.