Reading time: 15 minutes
git remote add command is a basic git command which add a remote repository as an origin of your local repository. The basic idea is that the remote repository is the final working repository which is considered by everyone and your local repository is your local copy holding your changes.
Using the command git remote -v, we can find out the remote repository for your local repository. As we have not added any remote origin repository, it will provide no information.
There are two types of remote repositories:
- remote fetch: the remote repository which you use as a baseline upon which you make your local changes
- remote push: the remote repository where you add your local changes
Usually, both remote repositories refer to different branches of the same repository like remote fetch is usually master branch and remote push is a feature branch like feature_1. In some cases, both can refer to the same branch as well. It is related to how the repository is being managed.
The concept is covered by this image:
Let us consider this repository
https://github.com/OpenGenus/test as our origin repository. Let us add it to our local repository. The format of the command is:
git remote add <name_of_your_remote_repository> <URL_of_your_remote_repository>
As we see, we have successfully add our GitHub repository as our remote repository.
We can, now, do much more interesting things with our repository and we have made your first step towards the distributed layer of Git.