Perhaps you’ve already got a project folder, and initiated git on the project with git init
. And let’s say you have an existing remote git repository for your project that you would like to use version your project. You can add the remote repository by using the git remote add
command.
The remote add
command takes two arguments. The first is a remote name, such as origin and the second argument is a URL for the remote repository. Putting it altogether, the command looks like this:
# This sets a new remote to the current git repo
git remote add origin https://github.com/user/repo.git
Once you set a new remote repository, you can verify that the remote was added correctly by running:
git remote -v
# This should yield something like this:
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)