How to add remote to existing local git repo

When you have a local folder with source code and want to push/pull you code from an existing repository on Github, you’ll need to add remote. This command applied not only Github but most git providers: Bitbucket, Gitlab, …

Syntax:

git remote add origin https://link-to-git-repo

In this case we’ll use default remote name = origin.

What is remote name?

The remote name is a short-hand label for a remote repository. “origin” is the conventional default name for the first remote and is usually where you push to when you don’t specify a remote for git.

You can set up more than one remote for your local repo and you use the remote name when pushing to them.

Related:  Difference between git remote add and git clone