Getting Git

A comprehensive video course from git init to Git Master.

init: git remote

In this video we'll learn how to use git remote.

A remote is a named reference to an external (or remote) copy of the repository.

When you clone a repository, Git automatically creates a remote named origin that references the clone URL.

Let's demonstrate this by running git remote –v.

From the output, we see the origin remote references our fork of the repository on GitHub.

In addition, it contains both fetch and push references for reading and writing to the repository. While these are set automatically and often reference the same URL, they may not be if the repository needs to read and write from different URLs.

One of the features that sets Git apart from other version control systems is its distributed nature.

Other version control systems often require a central repository. One that all users connect to and sync with.

As we've seen, that is not the case with Git.

So far, we've been able to run all the Git commands locally, without having to connect to a remote repository.

In addition, when we ran git clone we saw that it copied all of the files as well as the .git directory. This means even when we clone a remote repository, we have still have all of the information necessary to continue to manage a Git repository offline.

Even though there's not a technical requirement for a central server, you are free to formalize your own. In fact, it's common to use the repository on GitHub, Bitbucket, or GitLab as the central location.

While git remote is also not a command you'll use very often, you will reference remotes in many other Git commands.