What does "git remote" mean?

What does "remote" mean? When cloning a repository located at a central location, aren't we creating its remote version?

When I execute the command

$ git remote

I get origin. What does this mean?

When I execute

$ git branch -r

I get origin/master. Now what is this?


I found a fantastic answer here:

As you probably know, git is a distributed version control system. Most operations are done locally. To communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [email protected]:peter/first_app.git creates a new remote called origin located at [email protected]:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.

I would recommend reading the whole answer.


A remote in Git is basically a bookmark for a different repository from which you may wish to pull or push code.

The bookmarked repository may be on your local computer in a different folder, on remote server, or it may even be the repository itself (I haven't tried this), but the simplest analogy is a bookmark.

The repository doesn't even have to be a version of your repository, it may even be a completely unrelated repository.


Q) What does remote mean? When cloning a repository located at a central location, aren't we creating its remote version?
Answer:

Remote repositories are versions of your project that are hosted on the Internet or network somewhere.

So, your point of reference is the machine on which you are running your commands (your laptop) and ergo the central location where the repository is hosted for collaborators is the "remote".

Q) When I execute the command
$ git remote

I get origin. What does this mean?
Answer:

(git remote command) lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin – that is the default name Git gives to the server you cloned from.

Specifying git remote -v will give you the shortname and corresponding URL of the "remote" (AKA the repository).

Q) When I execute
$ git branch -r

I get origin/master. Now what is this?
Answer:

origin is the shortname created by Git for you to refer to your remote repository; master being the default branch pointing to the last commit Therefore, "git branch -r" will list the remote (origin) branch (master).

References:

  1. Git Basics - Working with Remotes
  2. Git Branching - Branches in a Nutshell