Git Remote – Add online repository

Git Remote is used to manage list of online repositories being tracked by you. Following is the syntax to add an online repository to the existing git remote list.

Syntax

The syntax of git command to add an online repository, without options which is generally used is

git remote add <name> <url>

The same git command to add an online repository with all available options is

git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
ADVERTISEMENT

Example

In the following example, we shall add an online repository to the git remote list, without any options.

git remote add origin https://github.com/tutorialkart/git-tutorial.git

Let us check the existing list in git remote

~$ git remote -v

Well! There are no any. Lets go and add https://github.com/tutorialkart/git-tutorial.git to the git remote with nameorigin. You may use any other name for the online (remote) repository

~$ git remote add origin https://github.com/tutorialkart/git-tutorial.git

The online repository has been added to git remote, with nameorigin. Check the list once again.

~$ git remote -v
origin	https://github.com/tutorialkart/git-tutorial.git (fetch)
origin	https://github.com/tutorialkart/git-tutorial.git (push)

The repository has been added for push and fetch operations.

Conclusion

In this Git Tutorial, we have learnt to add Remote/Online repository to git remote list.